• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 DRAW_CMD_H
17 #define DRAW_CMD_H
18 
19 #include <chrono>
20 #include <cstdint>
21 #include <ctime>
22 #include <functional>
23 #include <shared_mutex>
24 #include <stack>
25 #include <unordered_map>
26 #include <utility>
27 
28 #include "draw/canvas.h"
29 #include "draw/paint.h"
30 #include "recording/cmd_list.h"
31 
32 #define UNMARSHALLING_REGISTER(name, type, func, size) \
33     static bool isRegistered##name = OHOS::Rosen::Drawing::UnmarshallingHelper::Instance().Register(type, func, size)
34 
35 namespace OHOS {
36 namespace Rosen {
37 namespace Drawing {
38 class DrawCmdList;
39 class DRAWING_API DrawOpItem : public OpItem {
40 public:
DrawOpItem(uint32_t type)41     explicit DrawOpItem(uint32_t type) : OpItem(type) {}
42     ~DrawOpItem() override = default;
43 
44     enum Type : uint32_t {
45         OPITEM_HEAD,
46         POINT_OPITEM,
47         POINTS_OPITEM,
48         LINE_OPITEM,
49         RECT_OPITEM,
50         ROUND_RECT_OPITEM,
51         NESTED_ROUND_RECT_OPITEM,
52         ARC_OPITEM,
53         PIE_OPITEM,
54         OVAL_OPITEM,
55         CIRCLE_OPITEM,
56         COLOR_OPITEM,
57         IMAGE_NINE_OPITEM,
58         IMAGE_LATTICE_OPITEM,
59         PATH_OPITEM,
60         BACKGROUND_OPITEM,
61         SHADOW_OPITEM,
62         SHADOW_STYLE_OPITEM,
63         ATLAS_OPITEM,
64         BITMAP_OPITEM,
65         IMAGE_OPITEM,
66         IMAGE_RECT_OPITEM,
67         PICTURE_OPITEM,
68         TEXT_BLOB_OPITEM,
69         SYMBOL_OPITEM,
70         CLIP_RECT_OPITEM,
71         CLIP_IRECT_OPITEM,
72         CLIP_ROUND_RECT_OPITEM,
73         CLIP_PATH_OPITEM,
74         CLIP_REGION_OPITEM,
75         SET_MATRIX_OPITEM,
76         RESET_MATRIX_OPITEM,
77         CONCAT_MATRIX_OPITEM,
78         TRANSLATE_OPITEM,
79         SCALE_OPITEM,
80         ROTATE_OPITEM,
81         SHEAR_OPITEM,
82         FLUSH_OPITEM,
83         CLEAR_OPITEM,
84         SAVE_OPITEM,
85         SAVE_LAYER_OPITEM,
86         RESTORE_OPITEM,
87         DISCARD_OPITEM,
88         CLIP_ADAPTIVE_ROUND_RECT_OPITEM,
89         IMAGE_WITH_PARM_OPITEM,
90         PIXELMAP_WITH_PARM_OPITEM,
91         PIXELMAP_RECT_OPITEM,
92         PIXELMAP_NINE_OPITEM,
93         PIXELMAP_LATTICE_OPITEM,
94         REGION_OPITEM,
95         PATCH_OPITEM,
96         EDGEAAQUAD_OPITEM,
97         VERTICES_OPITEM,
98         IMAGE_SNAPSHOT_OPITEM,
99         SURFACEBUFFER_OPITEM,
100         DRAW_FUNC_OPITEM,
101         RECORD_CMD_OPITEM,
102         HYBRID_RENDER_PIXELMAP_OPITEM,
103         HYBRID_RENDER_PIXELMAP_SIZE_OPITEM,
104     };
105 
106     static void BrushHandleToBrush(const BrushHandle& brushHandle, const DrawCmdList& cmdList, Brush& brush);
107     static void BrushToBrushHandle(const Brush& brush, DrawCmdList& cmdList, BrushHandle& brushHandle);
108     static void GeneratePaintFromHandle(const PaintHandle& paintHandle, const DrawCmdList& cmdList, Paint& paint);
109     static void GenerateHandleFromPaint(CmdList& cmdList, const Paint& paint, PaintHandle& paintHandle);
110 
111     virtual void Marshalling(DrawCmdList& cmdList) = 0;
112     virtual void Playback(Canvas* canvas, const Rect* rect) = 0;
113 
SetNodeId(NodeId id)114     virtual void SetNodeId(NodeId id) {}
115     virtual void Dump(std::string& out) const;
116 
117     std::string GetOpDesc() const;
118 
119     static void SetBaseCallback(
120         std::function<void (std::shared_ptr<Drawing::Image> image)> holdDrawingImagefunc);
121     static std::function<void (std::shared_ptr<Drawing::Image> image)> holdDrawingImagefunc_;
122 
123     static void SetTypefaceQueryCallBack(
124         std::function<std::shared_ptr<Drawing::Typeface>(uint64_t)> customTypefaceQueryfunc);
125     static std::function<std::shared_ptr<Drawing::Typeface>(uint64_t)> customTypefaceQueryfunc_;
126 
Purge()127     virtual void Purge() {}
128 
129     size_t GetOpSize();
130 
GetOpItemCmdlistDrawRegion()131     virtual Rect GetOpItemCmdlistDrawRegion()
132     {
133         return Rect { 0, 0, 0, 0 };
134     }
135 };
136 
137 class DRAWING_API UnmarshallingHelper {
138     using UnmarshallingFunc = std::shared_ptr<DrawOpItem>(*)(const DrawCmdList& cmdList, void* handle);
139 public:
140     static UnmarshallingHelper& Instance();
141 
142     bool Register(uint32_t type, UnmarshallingFunc func, size_t unmarshallingSize);
143     std::pair<UnmarshallingFunc, size_t> GetFuncAndSize(uint32_t type);
144 
145 private:
146     UnmarshallingHelper() = default;
147     ~UnmarshallingHelper() = default;
148     UnmarshallingHelper(const UnmarshallingHelper& other) = delete;
149     UnmarshallingHelper(const UnmarshallingHelper&& other) = delete;
150     UnmarshallingHelper& operator=(const UnmarshallingHelper& other) = delete;
151     UnmarshallingHelper& operator=(const UnmarshallingHelper&& other) = delete;
152 
153     std::shared_mutex mtx_;
154     std::unordered_map<uint32_t, UnmarshallingFunc> opUnmarshallingFuncLUT_;
155     std::unordered_map<uint32_t, size_t> opUnmarshallingSize_;
156 };
157 
158 class UnmarshallingPlayer {
159 public:
160     UnmarshallingPlayer(const DrawCmdList& cmdList);
161     ~UnmarshallingPlayer() = default;
162 
163     std::shared_ptr<DrawOpItem> Unmarshalling(uint32_t type, void* handle, size_t availableSize, bool isReplayMode);
164 private:
165     const DrawCmdList& cmdList_;
166 };
167 
168 class GenerateCachedOpItemPlayer {
169 public:
170     GenerateCachedOpItemPlayer(DrawCmdList &cmdList, Canvas* canvas = nullptr, const Rect* rect = nullptr);
171     ~GenerateCachedOpItemPlayer() = default;
172 
173     bool GenerateCachedOpItem(uint32_t type, void* handle, size_t availableSize);
174 
175     Canvas* canvas_ = nullptr;
176     const Rect* rect_;
177     DrawCmdList& cmdList_;
178 };
179 
180 class DRAWING_API DrawWithPaintOpItem : public DrawOpItem {
181 public:
DrawWithPaintOpItem(const Paint & paint,uint32_t type)182     explicit DrawWithPaintOpItem(const Paint& paint, uint32_t type) : DrawOpItem(type), paint_(paint) {}
183     DrawWithPaintOpItem(const DrawCmdList& cmdList, const PaintHandle& paintHandle, uint32_t type);
184     ~DrawWithPaintOpItem() override = default;
Marshalling(DrawCmdList & cmdList)185     void Marshalling(DrawCmdList& cmdList) override {}
Playback(Canvas * canvas,const Rect * rect)186     void Playback(Canvas* canvas, const Rect* rect) override {}
187     virtual void Dump(std::string& out) const override;
DumpItems(std::string & out)188     virtual void DumpItems(std::string& out) const {}
189 protected:
190     Paint paint_;
191 };
192 
193 class DrawShadowStyleOpItem : public DrawOpItem {
194 public:
195     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle196         ConstructorHandle(const OpDataHandle& path, const Point3& planeParams, const Point3& devLightPos,
197             scalar lightRadius, Color ambientColor, Color spotColor, ShadowFlags flag, bool isLimitElevation)
198             : OpItem(DrawOpItem::SHADOW_STYLE_OPITEM),
199               path(path),
200               planeParams(planeParams),
201               devLightPos(devLightPos),
202               lightRadius(lightRadius),
203               ambientColor(ambientColor),
204               spotColor(spotColor),
205               flag(flag),
206               isLimitElevation(isLimitElevation)
207         {}
208         ~ConstructorHandle() override = default;
209         OpDataHandle path;
210         Point3 planeParams;
211         Point3 devLightPos;
212         scalar lightRadius;
213         Color ambientColor;
214         Color spotColor;
215         ShadowFlags flag;
216         bool isLimitElevation;
217     };
218     DrawShadowStyleOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawShadowStyleOpItem(const Path & path,const Point3 & planeParams,const Point3 & devLightPos,scalar lightRadius,Color ambientColor,Color spotColor,ShadowFlags flag,bool isLimitElevation)219     DrawShadowStyleOpItem(const Path& path, const Point3& planeParams, const Point3& devLightPos, scalar lightRadius,
220         Color ambientColor, Color spotColor, ShadowFlags flag, bool isLimitElevation)
221         : DrawOpItem(DrawOpItem::SHADOW_STYLE_OPITEM),
222           planeParams_(planeParams),
223           devLightPos_(devLightPos),
224           lightRadius_(lightRadius),
225           ambientColor_(ambientColor),
226           spotColor_(spotColor),
227           flag_(flag),
228           isLimitElevation_(isLimitElevation),
229           path_(std::make_shared<Path>(path))
230     {}
231     ~DrawShadowStyleOpItem() override = default;
232 
233     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
234     void Marshalling(DrawCmdList& cmdList) override;
235     void Playback(Canvas* canvas, const Rect* rect) override;
236     void Dump(std::string& out) const override;
237 private:
238     Point3 planeParams_;
239     Point3 devLightPos_;
240     scalar lightRadius_;
241     Color ambientColor_;
242     Color spotColor_;
243     ShadowFlags flag_;
244     bool isLimitElevation_;
245     std::shared_ptr<Path> path_;
246 };
247 
248 class DrawPointOpItem : public DrawWithPaintOpItem {
249 public:
250     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle251         ConstructorHandle(const Point& point, const PaintHandle& paintHandle)
252             : OpItem(DrawOpItem::POINT_OPITEM), point(point), paintHandle(paintHandle) {}
253         ~ConstructorHandle() override = default;
254         Point point;
255         PaintHandle paintHandle;
256     };
257     DrawPointOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawPointOpItem(const Point & point,const Paint & paint)258     explicit DrawPointOpItem(const Point& point, const Paint& paint)
259         : DrawWithPaintOpItem(paint, DrawOpItem::POINT_OPITEM), point_(point) {}
260     ~DrawPointOpItem() override = default;
261 
262     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
263     void Marshalling(DrawCmdList& cmdList) override;
264     void Playback(Canvas* canvas, const Rect* rect) override;
265     virtual void DumpItems(std::string& out) const override;
266 private:
267     Point point_;
268 };
269 
270 class DrawPointsOpItem : public DrawWithPaintOpItem {
271 public:
272     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle273         ConstructorHandle(PointMode mode, const std::pair<size_t, size_t>& pts, const PaintHandle& paintHandle)
274             : OpItem(DrawOpItem::POINTS_OPITEM), mode(mode), pts(pts), paintHandle(paintHandle) {}
275         ~ConstructorHandle() override = default;
276         PointMode mode;
277         std::pair<size_t, size_t> pts;
278         PaintHandle paintHandle;
279     };
280     DrawPointsOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawPointsOpItem(PointMode mode,std::vector<Point> & pts,const Paint & paint)281     DrawPointsOpItem(PointMode mode, std::vector<Point>& pts, const Paint& paint)
282         : DrawWithPaintOpItem(paint, DrawOpItem::POINTS_OPITEM), mode_(mode), pts_(pts) {}
283     ~DrawPointsOpItem() override = default;
284 
285     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
286     void Marshalling(DrawCmdList& cmdList) override;
287     void Playback(Canvas* canvas, const Rect* rect) override;
288 private:
289     PointMode mode_;
290     std::vector<Point> pts_;
291 };
292 
293 class DrawLineOpItem : public DrawWithPaintOpItem {
294 public:
295     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle296         ConstructorHandle(const Point& startPt, const Point& endPt, const PaintHandle& paintHandle)
297             : OpItem(DrawOpItem::LINE_OPITEM), startPt(startPt), endPt(endPt), paintHandle(paintHandle) {}
298         ~ConstructorHandle() override = default;
299         Point startPt;
300         Point endPt;
301         PaintHandle paintHandle;
302     };
303     DrawLineOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawLineOpItem(const Point & startPt,const Point & endPt,const Paint & paint)304     DrawLineOpItem(const Point& startPt, const Point& endPt, const Paint& paint)
305         : DrawWithPaintOpItem(paint, DrawOpItem::LINE_OPITEM), startPt_(startPt), endPt_(endPt) {}
306     ~DrawLineOpItem() override = default;
307 
308     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
309     void Marshalling(DrawCmdList& cmdList) override;
310     void Playback(Canvas* canvas, const Rect* rect) override;
311     virtual void DumpItems(std::string& out) const override;
312 private:
313     Point startPt_;
314     Point endPt_;
315 };
316 
317 class DrawRectOpItem : public DrawWithPaintOpItem {
318 public:
319     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle320         ConstructorHandle(const Rect& rect, const PaintHandle& paintHandle)
321             : OpItem(DrawOpItem::RECT_OPITEM), rect(rect), paintHandle(paintHandle) {}
322         ~ConstructorHandle() override = default;
323         Rect rect;
324         PaintHandle paintHandle;
325     };
326     DrawRectOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawRectOpItem(const Rect & rect,const Paint & paint)327     explicit DrawRectOpItem(const Rect& rect, const Paint& paint)
328         : DrawWithPaintOpItem(paint, DrawOpItem::RECT_OPITEM), rect_(rect) {}
329     ~DrawRectOpItem() override = default;
330 
331     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
332     void Marshalling(DrawCmdList& cmdList) override;
333     void Playback(Canvas* canvas, const Rect* rect) override;
334     virtual void DumpItems(std::string& out) const override;
335     Rect GetOpItemCmdlistDrawRegion() override;
336 private:
337     Rect rect_;
338 };
339 
340 class DrawRoundRectOpItem : public DrawWithPaintOpItem {
341 public:
342     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle343         ConstructorHandle(const RoundRect& rrect, const PaintHandle& paintHandle)
344             : OpItem(DrawOpItem::ROUND_RECT_OPITEM), rrect(rrect), paintHandle(paintHandle) {}
345         ~ConstructorHandle() override = default;
346         RoundRect rrect;
347         PaintHandle paintHandle;
348     };
349     DrawRoundRectOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawRoundRectOpItem(const RoundRect & rrect,const Paint & paint)350     explicit DrawRoundRectOpItem(const RoundRect& rrect, const Paint& paint)
351         : DrawWithPaintOpItem(paint, DrawOpItem::ROUND_RECT_OPITEM), rrect_(rrect) {}
352     ~DrawRoundRectOpItem() override = default;
353 
354     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
355     void Marshalling(DrawCmdList& cmdList) override;
356     void Playback(Canvas* canvas, const Rect* rect) override;
357     virtual void DumpItems(std::string& out) const override;
358 private:
359     RoundRect rrect_;
360 };
361 
362 class DrawNestedRoundRectOpItem : public DrawWithPaintOpItem {
363 public:
364     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle365         ConstructorHandle(const RoundRect& outerRRect, const RoundRect& innerRRect, const PaintHandle& paintHandle)
366             : OpItem(DrawOpItem::NESTED_ROUND_RECT_OPITEM), outerRRect(outerRRect), innerRRect(innerRRect),
367               paintHandle(paintHandle) {}
368         ~ConstructorHandle() override = default;
369         RoundRect outerRRect;
370         RoundRect innerRRect;
371         PaintHandle paintHandle;
372     };
373     DrawNestedRoundRectOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawNestedRoundRectOpItem(const RoundRect & outer,const RoundRect & inner,const Paint & paint)374     DrawNestedRoundRectOpItem(const RoundRect& outer, const RoundRect& inner, const Paint& paint)
375         : DrawWithPaintOpItem(paint, DrawOpItem::NESTED_ROUND_RECT_OPITEM), outerRRect_(outer), innerRRect_(inner) {}
376     ~DrawNestedRoundRectOpItem() override = default;
377 
378     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
379     void Marshalling(DrawCmdList& cmdList) override;
380     void Playback(Canvas* canvas, const Rect* rect) override;
381     virtual void DumpItems(std::string& out) const override;
382 private:
383     RoundRect outerRRect_;
384     RoundRect innerRRect_;
385 };
386 
387 class DrawArcOpItem : public DrawWithPaintOpItem {
388 public:
389     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle390         ConstructorHandle(const Rect& rect, scalar startAngle, scalar sweepAngle, const PaintHandle& paintHandle)
391             : OpItem(DrawOpItem::ARC_OPITEM), rect(rect), startAngle(startAngle), sweepAngle(sweepAngle),
392               paintHandle(paintHandle) {}
393         ~ConstructorHandle() override = default;
394         Rect rect;
395         scalar startAngle;
396         scalar sweepAngle;
397         PaintHandle paintHandle;
398     };
399     DrawArcOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawArcOpItem(const Rect & oval,scalar startAngle,scalar sweepAngle,const Paint & paint)400     DrawArcOpItem(const Rect& oval, scalar startAngle, scalar sweepAngle, const Paint& paint)
401         : DrawWithPaintOpItem(paint, DrawOpItem::ARC_OPITEM), rect_(oval), startAngle_(startAngle),
402           sweepAngle_(sweepAngle) {}
403     ~DrawArcOpItem() override = default;
404 
405     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
406     void Marshalling(DrawCmdList& cmdList) override;
407     void Playback(Canvas* canvas, const Rect* rect) override;
408     virtual void DumpItems(std::string& out) const override;
409 private:
410     Rect rect_;
411     scalar startAngle_;
412     scalar sweepAngle_;
413 };
414 
415 class DrawPieOpItem : public DrawWithPaintOpItem {
416 public:
417     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle418         ConstructorHandle(const Rect& rect, scalar startAngle, scalar sweepAngle, const PaintHandle& paintHandle)
419             : OpItem(DrawOpItem::PIE_OPITEM), rect(rect), startAngle(startAngle), sweepAngle(sweepAngle),
420               paintHandle(paintHandle) {}
421         ~ConstructorHandle() override = default;
422         Rect rect;
423         scalar startAngle;
424         scalar sweepAngle;
425         PaintHandle paintHandle;
426     };
427     DrawPieOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawPieOpItem(const Rect & oval,scalar startAngle,scalar sweepAngle,const Paint & paint)428     DrawPieOpItem(const Rect& oval, scalar startAngle, scalar sweepAngle, const Paint& paint)
429         : DrawWithPaintOpItem(paint, DrawOpItem::PIE_OPITEM), rect_(oval), startAngle_(startAngle),
430           sweepAngle_(sweepAngle) {}
431     ~DrawPieOpItem() override = default;
432 
433     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
434     void Marshalling(DrawCmdList& cmdList) override;
435     void Playback(Canvas* canvas, const Rect* rect) override;
436     virtual void DumpItems(std::string& out) const override;
437 private:
438     Rect rect_;
439     scalar startAngle_;
440     scalar sweepAngle_;
441 };
442 
443 class DrawOvalOpItem : public DrawWithPaintOpItem {
444 public:
445     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle446         ConstructorHandle(const Rect& rect, const PaintHandle& paintHandle)
447             : OpItem(DrawOpItem::OVAL_OPITEM), rect(rect), paintHandle(paintHandle) {}
448         ~ConstructorHandle() override = default;
449         Rect rect;
450         PaintHandle paintHandle;
451     };
452     DrawOvalOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawOvalOpItem(const Rect & oval,const Paint & paint)453     explicit DrawOvalOpItem(const Rect& oval, const Paint& paint)
454         : DrawWithPaintOpItem(paint, DrawOpItem::OVAL_OPITEM), rect_(oval) {}
455     ~DrawOvalOpItem() override = default;
456 
457     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
458     void Marshalling(DrawCmdList& cmdList) override;
459     void Playback(Canvas* canvas, const Rect* rect) override;
460     virtual void DumpItems(std::string& out) const override;
461 private:
462     Rect rect_;
463 };
464 
465 class DrawCircleOpItem : public DrawWithPaintOpItem {
466 public:
467     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle468         ConstructorHandle(const Point& centerPt, scalar radius, const PaintHandle& paintHandle)
469             : OpItem(DrawOpItem::CIRCLE_OPITEM), centerPt(centerPt), radius(radius), paintHandle(paintHandle) {}
470         ~ConstructorHandle() override = default;
471         Point centerPt;
472         scalar radius;
473         PaintHandle paintHandle;
474     };
475     DrawCircleOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawCircleOpItem(const Point & centerPt,scalar radius,const Paint & paint)476     DrawCircleOpItem(const Point& centerPt, scalar radius, const Paint& paint)
477         : DrawWithPaintOpItem(paint, DrawOpItem::CIRCLE_OPITEM), centerPt_(centerPt), radius_(radius) {}
478     ~DrawCircleOpItem() override = default;
479 
480     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
481     void Marshalling(DrawCmdList& cmdList) override;
482     void Playback(Canvas* canvas, const Rect* rect) override;
483     virtual void DumpItems(std::string& out) const override;
484 private:
485     Point centerPt_;
486     scalar radius_;
487 };
488 
489 class DrawPathOpItem : public DrawWithPaintOpItem {
490 public:
491     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle492         ConstructorHandle(const OpDataHandle& path, const PaintHandle& paintHandle)
493             : OpItem(DrawOpItem::PATH_OPITEM), path(path), paintHandle(paintHandle) {}
494         ~ConstructorHandle() override = default;
495         OpDataHandle path;
496         PaintHandle paintHandle;
497     };
498     DrawPathOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawPathOpItem(const Path & path,const Paint & paint)499     explicit DrawPathOpItem(const Path& path, const Paint& paint)
500         : DrawWithPaintOpItem(paint, DrawOpItem::PATH_OPITEM), path_(std::make_shared<Path>(path)) {}
501     ~DrawPathOpItem() override = default;
502 
503     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
504     void Marshalling(DrawCmdList& cmdList) override;
505     void Playback(Canvas* canvas, const Rect* rect) override;
506     void DumpItems(std::string& out) const override;
507     Rect GetOpItemCmdlistDrawRegion() override;
508 private:
509     std::shared_ptr<Path> path_;
510 };
511 
512 class DrawBackgroundOpItem : public DrawOpItem {
513 public:
514     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle515         ConstructorHandle(const BrushHandle& brushHandle)
516             : OpItem(DrawOpItem::BACKGROUND_OPITEM), brushHandle(brushHandle) {}
517         ~ConstructorHandle() override = default;
518         BrushHandle brushHandle;
519     };
520     DrawBackgroundOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawBackgroundOpItem(const Brush & brush)521     explicit DrawBackgroundOpItem(const Brush& brush) : DrawOpItem(DrawOpItem::BACKGROUND_OPITEM), brush_(brush) {}
522     ~DrawBackgroundOpItem() override = default;
523 
524     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
525     void Marshalling(DrawCmdList& cmdList) override;
526     void Playback(Canvas* canvas, const Rect* rect) override;
527 private:
528     Brush brush_;
529 };
530 
531 class DrawShadowOpItem : public DrawOpItem {
532 public:
533     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle534         ConstructorHandle(const OpDataHandle& path, const Point3& planeParams, const Point3& devLightPos,
535             scalar lightRadius, Color ambientColor, Color spotColor, ShadowFlags flag)
536             : OpItem(DrawOpItem::SHADOW_OPITEM), path(path), planeParams(planeParams), devLightPos(devLightPos),
537             lightRadius(lightRadius), ambientColor(ambientColor), spotColor(spotColor), flag(flag) {}
538         ~ConstructorHandle() override = default;
539         OpDataHandle path;
540         Point3 planeParams;
541         Point3 devLightPos;
542         scalar lightRadius;
543         Color ambientColor;
544         Color spotColor;
545         ShadowFlags flag;
546     };
547     DrawShadowOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawShadowOpItem(const Path & path,const Point3 & planeParams,const Point3 & devLightPos,scalar lightRadius,Color ambientColor,Color spotColor,ShadowFlags flag)548     DrawShadowOpItem(const Path& path, const Point3& planeParams, const Point3& devLightPos, scalar lightRadius,
549         Color ambientColor, Color spotColor, ShadowFlags flag)
550         : DrawOpItem(DrawOpItem::SHADOW_OPITEM), planeParams_(planeParams), devLightPos_(devLightPos),
551           lightRadius_(lightRadius), ambientColor_(ambientColor), spotColor_(spotColor), flag_(flag),
552           path_(std::make_shared<Path>(path)) {}
553     ~DrawShadowOpItem() override = default;
554 
555     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
556     void Marshalling(DrawCmdList& cmdList) override;
557     void Playback(Canvas* canvas, const Rect* rect) override;
558     void Dump(std::string& out) const override;
559 private:
560     Point3 planeParams_;
561     Point3 devLightPos_;
562     scalar lightRadius_;
563     Color ambientColor_;
564     Color spotColor_;
565     ShadowFlags flag_;
566     std::shared_ptr<Path> path_;
567 };
568 
569 class DrawRegionOpItem : public DrawWithPaintOpItem {
570 public:
571     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle572         ConstructorHandle(const OpDataHandle& region, const PaintHandle& paintHandle)
573             : OpItem(DrawOpItem::REGION_OPITEM), region(region), paintHandle(paintHandle) {}
574         ~ConstructorHandle() override = default;
575         OpDataHandle region;
576         PaintHandle paintHandle;
577     };
578     DrawRegionOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawRegionOpItem(const Region & region,const Paint & paint)579     explicit DrawRegionOpItem(const Region& region, const Paint& paint)
580         : DrawWithPaintOpItem(paint, DrawOpItem::REGION_OPITEM), region_(std::make_shared<Region>(region)) {}
581     ~DrawRegionOpItem() override = default;
582 
583     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
584     void Marshalling(DrawCmdList& cmdList) override;
585     void Playback(Canvas* canvas, const Rect* rect) override;
586     void DumpItems(std::string& out) const override;
587 private:
588     std::shared_ptr<Region> region_;
589 };
590 
591 class DrawVerticesOpItem : public DrawWithPaintOpItem {
592 public:
593     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle594         ConstructorHandle(const OpDataHandle& vertices, BlendMode mode, const PaintHandle& paintHandle)
595             : OpItem(DrawOpItem::VERTICES_OPITEM), vertices(vertices), mode(mode), paintHandle(paintHandle) {}
596         ~ConstructorHandle() override = default;
597         OpDataHandle vertices;
598         BlendMode mode;
599         PaintHandle paintHandle;
600     };
601     DrawVerticesOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawVerticesOpItem(const Vertices & vertices,BlendMode mode,const Paint & paint)602     DrawVerticesOpItem(const Vertices& vertices, BlendMode mode, const Paint& paint)
603         : DrawWithPaintOpItem(paint, DrawOpItem::VERTICES_OPITEM), mode_(mode),
604           vertices_(std::make_shared<Vertices>(vertices)) {}
605     ~DrawVerticesOpItem() override = default;
606 
607     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
608     void Marshalling(DrawCmdList& cmdList) override;
609     void Playback(Canvas* canvas, const Rect* rect) override;
610     void DumpItems(std::string& out) const override;
611 private:
612     BlendMode mode_;
613     std::shared_ptr<Vertices> vertices_;
614 };
615 
616 class DrawColorOpItem : public DrawOpItem {
617 public:
618     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle619         ConstructorHandle(ColorQuad color, BlendMode mode)
620             : OpItem(DrawOpItem::COLOR_OPITEM), color(color), mode(mode) {}
621         ~ConstructorHandle() override = default;
622         ColorQuad color;
623         BlendMode mode;
624     };
625     explicit DrawColorOpItem(ConstructorHandle* handle);
DrawColorOpItem(ColorQuad color,BlendMode mode)626     DrawColorOpItem(ColorQuad color, BlendMode mode)
627         : DrawOpItem(DrawOpItem::COLOR_OPITEM), color_(color), mode_(mode) {}
628     ~DrawColorOpItem() override = default;
629 
630     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
631     void Marshalling(DrawCmdList& cmdList) override;
632     void Playback(Canvas* canvas, const Rect* rect) override;
633     void Dump(std::string& out) const override;
634 private:
635     ColorQuad color_;
636     BlendMode mode_;
637 };
638 
639 class DrawImageNineOpItem : public DrawOpItem {
640 public:
641     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle642         ConstructorHandle(const OpDataHandle& image, const RectI& center, const Rect& dst, FilterMode filterMode,
643             const BrushHandle& brushHandle, bool hasBrush) : OpItem(DrawOpItem::IMAGE_NINE_OPITEM), image(image),
644             center(center), dst(dst), filter(filterMode), brushHandle(brushHandle), hasBrush(hasBrush) {}
645         ~ConstructorHandle() override = default;
646         OpDataHandle image;
647         RectI center;
648         Rect dst;
649         FilterMode filter;
650         BrushHandle brushHandle;
651         bool hasBrush;
652     };
653     DrawImageNineOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawImageNineOpItem(const Image * image,const RectI & center,const Rect & dst,FilterMode filterMode,const Brush * brush)654     DrawImageNineOpItem(const Image* image, const RectI& center, const Rect& dst, FilterMode filterMode,
655         const Brush* brush) : DrawOpItem(DrawOpItem::IMAGE_NINE_OPITEM), center_(center), dst_(dst), filter_(filterMode)
656     {
657         if (brush) {
658             hasBrush_ = true;
659             brush_ = *brush;
660         } else {
661             hasBrush_ = false;
662         }
663         image_ = std::make_shared<Image>(*image);
664     }
665     ~DrawImageNineOpItem() override = default;
666 
667     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
668     void Marshalling(DrawCmdList& cmdList) override;
669     void Playback(Canvas* canvas, const Rect* rect) override;
670     void Dump(std::string& out) const override;
671 private:
672     RectI center_;
673     Rect dst_;
674     FilterMode filter_;
675     bool hasBrush_;
676     Brush brush_;
677     std::shared_ptr<Image> image_;
678 };
679 
680 class DrawImageLatticeOpItem : public DrawWithPaintOpItem {
681 public:
682     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle683         ConstructorHandle(const OpDataHandle& image, const LatticeHandle& latticeHandle, const Rect& dst,
684             FilterMode filterMode, const PaintHandle& paintHandle) : OpItem(DrawOpItem::IMAGE_LATTICE_OPITEM),
685             image(image), latticeHandle(latticeHandle), dst(dst), filter(filterMode), paintHandle(paintHandle) {}
686         ~ConstructorHandle() override = default;
687         OpDataHandle image;
688         LatticeHandle latticeHandle;
689         Rect dst;
690         FilterMode filter;
691         PaintHandle paintHandle;
692     };
693     DrawImageLatticeOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawImageLatticeOpItem(const Image * image,const Lattice & lattice,const Rect & dst,FilterMode filterMode,const Paint & paint)694     DrawImageLatticeOpItem(const Image* image, const Lattice& lattice, const Rect& dst, FilterMode filterMode,
695         const Paint& paint) : DrawWithPaintOpItem(paint, DrawOpItem::IMAGE_LATTICE_OPITEM), lattice_(lattice),
696         dst_(dst), filter_(filterMode), image_(std::make_shared<Image>(*image)) {}
697     ~DrawImageLatticeOpItem() override = default;
698 
699     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
700     void Marshalling(DrawCmdList& cmdList) override;
701     void Playback(Canvas* canvas, const Rect* rect) override;
702     void Dump(std::string& out) const override;
703 private:
704     Lattice lattice_;
705     Rect dst_;
706     FilterMode filter_;
707     std::shared_ptr<Image> image_;
708 };
709 
710 class DrawAtlasOpItem : public DrawWithPaintOpItem {
711 public:
712     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle713         ConstructorHandle(const OpDataHandle& atlas, const std::pair<size_t, size_t>& xform,
714             const std::pair<size_t, size_t>& tex, const std::pair<size_t, size_t>& colors, BlendMode mode,
715             const SamplingOptions& samplingOptions, bool hasCullRect, const Rect& cullRect,
716             const PaintHandle& paintHandle)
717             : OpItem(DrawOpItem::ATLAS_OPITEM), atlas(atlas), xform(xform), tex(tex), colors(colors), mode(mode),
718               samplingOptions(samplingOptions), hasCullRect(hasCullRect), cullRect(cullRect),
719               paintHandle(paintHandle) {}
720         ~ConstructorHandle() override = default;
721         OpDataHandle atlas;
722         std::pair<size_t, size_t> xform;
723         std::pair<size_t, size_t> tex;
724         std::pair<size_t, size_t> colors;
725         BlendMode mode;
726         SamplingOptions samplingOptions;
727         bool hasCullRect;
728         Rect cullRect;
729         PaintHandle paintHandle;
730     };
731     DrawAtlasOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawAtlasOpItem(const Image * atlas,const std::vector<RSXform> & xform,const std::vector<Rect> & tex,const std::vector<ColorQuad> & colors,BlendMode mode,const SamplingOptions & samplingOptions,bool hasCullRect,const Rect & cullRect,const Paint & paint)732     DrawAtlasOpItem(const Image* atlas, const std::vector<RSXform>& xform,
733         const std::vector<Rect>& tex, const std::vector<ColorQuad>& colors, BlendMode mode,
734         const SamplingOptions& samplingOptions, bool hasCullRect, const Rect& cullRect, const Paint& paint)
735         : DrawWithPaintOpItem(paint, DrawOpItem::ATLAS_OPITEM), xform_(xform), tex_(tex), colors_(colors), mode_(mode),
736           samplingOptions_(samplingOptions), hasCullRect_(hasCullRect), cullRect_(cullRect),
737           atlas_(std::make_shared<Image>(*atlas)) {}
738     ~DrawAtlasOpItem() override = default;
739 
740     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
741     void Marshalling(DrawCmdList& cmdList) override;
742     void Playback(Canvas* canvas, const Rect* rect) override;
743     void DumpItems(std::string& out) const override;
744 private:
745     std::vector<RSXform> xform_;
746     std::vector<Rect> tex_;
747     std::vector<ColorQuad> colors_;
748     BlendMode mode_;
749     SamplingOptions samplingOptions_;
750     bool hasCullRect_;
751     Rect cullRect_;
752     std::shared_ptr<Image> atlas_;
753 };
754 
755 class DrawBitmapOpItem : public DrawWithPaintOpItem {
756 public:
757     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle758         ConstructorHandle(const ImageHandle& bitmap, scalar px, scalar py, const PaintHandle& paintHandle)
759             : OpItem(DrawOpItem::BITMAP_OPITEM), bitmap(bitmap), px(px), py(py), paintHandle(paintHandle) {}
760         ~ConstructorHandle() override = default;
761         ImageHandle bitmap;
762         scalar px;
763         scalar py;
764         PaintHandle paintHandle;
765     };
766     DrawBitmapOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawBitmapOpItem(const Bitmap & bitmap,const scalar px,const scalar py,const Paint & paint)767     DrawBitmapOpItem(const Bitmap& bitmap, const scalar px, const scalar py, const Paint& paint)
768         : DrawWithPaintOpItem(paint, DrawOpItem::BITMAP_OPITEM), px_(px), py_(py),
769           bitmap_(std::make_shared<Bitmap>(bitmap)) {}
770     ~DrawBitmapOpItem() override = default;
771 
772     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
773     void Marshalling(DrawCmdList& cmdList) override;
774     void Playback(Canvas* canvas, const Rect* rect) override;
775     void DumpItems(std::string& out) const override;
776 private:
777     scalar px_;
778     scalar py_;
779     std::shared_ptr<Bitmap> bitmap_;
780 };
781 
782 class DrawImageOpItem : public DrawWithPaintOpItem {
783 public:
784     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle785         ConstructorHandle(const OpDataHandle& image, scalar px, scalar py, const SamplingOptions& samplingOptions,
786             const PaintHandle& paintHandle)
787             : OpItem(DrawOpItem::IMAGE_OPITEM), image(image), px(px), py(py), samplingOptions(samplingOptions),
788               paintHandle(paintHandle) {}
789         ~ConstructorHandle() override = default;
790         OpDataHandle image;
791         scalar px;
792         scalar py;
793         SamplingOptions samplingOptions;
794         PaintHandle paintHandle;
795     };
796     DrawImageOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawImageOpItem(const Image & image,const scalar px,const scalar py,const SamplingOptions & sampling,const Paint & paint)797     DrawImageOpItem(const Image& image, const scalar px, const scalar py, const SamplingOptions& sampling,
798         const Paint& paint) : DrawWithPaintOpItem(paint, DrawOpItem::IMAGE_OPITEM), px_(px), py_(py),
799         samplingOptions_(sampling), image_(std::make_shared<Image>(image)) {}
800     ~DrawImageOpItem() override = default;
801 
802     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
803     void Marshalling(DrawCmdList& cmdList) override;
804     void Playback(Canvas* canvas, const Rect* rect) override;
805     void DumpItems(std::string& out) const override;
806 private:
807     scalar px_;
808     scalar py_;
809     SamplingOptions samplingOptions_;
810     std::shared_ptr<Image> image_;
811 };
812 
813 class DrawImageRectOpItem : public DrawWithPaintOpItem {
814 public:
815     struct ConstructorHandle : public OpItem {
816         ConstructorHandle(const OpDataHandle& image, const Rect& src, const Rect& dst, const SamplingOptions& sampling,
817             SrcRectConstraint constraint, const PaintHandle& paintHandle, bool isForeground = false)
OpItemConstructorHandle818             : OpItem(DrawOpItem::IMAGE_RECT_OPITEM), image(image), src(src), dst(dst),
819               sampling(sampling), constraint(constraint), paintHandle(paintHandle), isForeground(isForeground) {}
820         ~ConstructorHandle() override = default;
821         OpDataHandle image;
822         Rect src;
823         Rect dst;
824         SamplingOptions sampling;
825         SrcRectConstraint constraint;
826         PaintHandle paintHandle;
827         bool isForeground;
828     };
829     DrawImageRectOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
830     DrawImageRectOpItem(const Image& image, const Rect& src, const Rect& dst, const SamplingOptions& sampling,
831         SrcRectConstraint constraint, const Paint& paint, bool isForeground = false);
832     ~DrawImageRectOpItem() override = default;
833 
834     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
835     void Marshalling(DrawCmdList& cmdList) override;
836     void Playback(Canvas* canvas, const Rect* rect) override;
837     void DumpItems(std::string& out) const override;
838 private:
839     Rect src_;
840     Rect dst_;
841     SamplingOptions sampling_;
842     SrcRectConstraint constraint_;
843     std::shared_ptr<Image> image_;
844     bool isForeground_ = false;
845 };
846 
847 class DrawRecordCmdOpItem : public DrawOpItem {
848 public:
849     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle850         ConstructorHandle(const OpDataHandle& recordCmdHandle, const Matrix::Buffer& matrixBuffer,
851             bool hasBrush, const BrushHandle& brushHandle)
852             : OpItem(DrawOpItem::RECORD_CMD_OPITEM), recordCmdHandle(recordCmdHandle),
853             matrixBuffer(matrixBuffer), hasBrush(hasBrush), brushHandle(brushHandle) {}
854         ~ConstructorHandle() override = default;
855         OpDataHandle recordCmdHandle;
856         Matrix::Buffer matrixBuffer;
857         bool hasBrush = false;
858         BrushHandle brushHandle;
859     };
860     DrawRecordCmdOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
861     explicit DrawRecordCmdOpItem(const std::shared_ptr<RecordCmd>& recordCmd,
862         const Matrix* matrix, const Brush* brush);
863     ~DrawRecordCmdOpItem() override = default;
864 
865     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
866     void Marshalling(DrawCmdList& cmdList) override;
867     void Playback(Canvas* canvas, const Rect* rect) override;
868 private:
869     std::shared_ptr<RecordCmd> recordCmd_ = nullptr;
870     Matrix matrix_;
871     bool hasBrush_ = false;
872     Brush brush_;
873 };
874 
875 class DrawPictureOpItem : public DrawOpItem {
876 public:
877     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle878         ConstructorHandle(const OpDataHandle& picture) : OpItem(DrawOpItem::PICTURE_OPITEM), picture(picture) {}
879         ~ConstructorHandle() override = default;
880         OpDataHandle picture;
881     };
882     DrawPictureOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawPictureOpItem(const Picture & picture)883     explicit DrawPictureOpItem(const Picture& picture)
884         : DrawOpItem(DrawOpItem::PICTURE_OPITEM), picture_(std::make_shared<Picture>(picture)) {}
885     ~DrawPictureOpItem() override = default;
886 
887     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
888     void Marshalling(DrawCmdList& cmdList) override;
889     void Playback(Canvas* canvas, const Rect* rect) override;
890 private:
891     std::shared_ptr<Picture> picture_;
892 };
893 
894 class DrawTextBlobOpItem : public DrawWithPaintOpItem {
895 public:
896     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle897         ConstructorHandle(const OpDataHandle& textBlob, const uint64_t& globalUniqueId,
898             TextContrast textContrast, scalar x, scalar y, const PaintHandle& paintHandle)
899             : OpItem(DrawOpItem::TEXT_BLOB_OPITEM), textBlob(textBlob), globalUniqueId(globalUniqueId),
900             textContrast(textContrast), x(x), y(y), paintHandle(paintHandle) {}
901         ~ConstructorHandle() override = default;
902         static bool GenerateCachedOpItem(DrawCmdList& cmdList, const TextBlob* textBlob, scalar x, scalar y, Paint& p);
903         bool GenerateCachedOpItem(DrawCmdList& cmdList, Canvas* canvas);
904         OpDataHandle textBlob;
905         uint64_t globalUniqueId;
906         TextContrast textContrast;
907         scalar x;
908         scalar y;
909         PaintHandle paintHandle;
910     };
911     DrawTextBlobOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawTextBlobOpItem(const TextBlob * blob,const scalar x,const scalar y,const Paint & paint)912     DrawTextBlobOpItem(const TextBlob* blob, const scalar x, const scalar y, const Paint& paint)
913         : DrawWithPaintOpItem(paint, DrawOpItem::TEXT_BLOB_OPITEM), x_(x), y_(y),
914           textBlob_(std::make_shared<TextBlob>(*blob)), globalUniqueId_(0) {}
915     ~DrawTextBlobOpItem() override = default;
916 
917     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
918     void Marshalling(DrawCmdList& cmdList) override;
919     void Playback(Canvas* canvas, const Rect* rect) override;
920     virtual void DumpItems(std::string& out) const override;
921 
922     std::shared_ptr<DrawImageRectOpItem> GenerateCachedOpItem(Canvas* canvas);
923     uint64_t GetTypefaceId();
924     Rect GetOpItemCmdlistDrawRegion() override;
925 protected:
926     void DrawHighContrast(Canvas* canvas, bool offSreen = false) const;
927     void DrawHighContrastEnabled(Canvas* canvas) const;
928     bool GetOffScreenSurfaceAndCanvas(const Canvas& canvas,
929         std::shared_ptr<Drawing::Surface>& offScreenSurface, std::shared_ptr<Canvas>& offScreenCanvas) const;
930 private:
931     scalar x_;
932     scalar y_;
933     std::shared_ptr<TextBlob> textBlob_;
934     uint64_t globalUniqueId_;
935     TextContrast textContrast_ = TextContrast::FOLLOW_SYSTEM;
936     bool IsHighContrastEnable(Canvas* canvas, TextContrast value) const;
937 };
938 
939 class DrawSymbolOpItem : public DrawWithPaintOpItem {
940 public:
941     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle942         ConstructorHandle(const SymbolOpHandle& symbolHandle, Point locate, const PaintHandle& paintHandle)
943             : OpItem(DrawOpItem::SYMBOL_OPITEM), symbolHandle(symbolHandle), locate(locate), paintHandle(paintHandle) {}
944         ~ConstructorHandle() override = default;
945         SymbolOpHandle symbolHandle;
946         Point locate;
947         PaintHandle paintHandle;
948     };
949     DrawSymbolOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
DrawSymbolOpItem(const DrawingHMSymbolData & symbol,Point locate,const Paint & paint)950     DrawSymbolOpItem(const DrawingHMSymbolData& symbol, Point locate, const Paint& paint)
951         : DrawWithPaintOpItem(paint, DrawOpItem::SYMBOL_OPITEM), symbol_(symbol), locate_(locate) {}
952     ~DrawSymbolOpItem() override = default;
953 
954     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
955     void Marshalling(DrawCmdList& cmdList) override;
956     void Playback(Canvas* canvas, const Rect* rect) override;
957     virtual void DumpItems(std::string& out) const override;
958 
959 private:
960     static void MergeDrawingPath(
961         Path& multPath, DrawingRenderGroup& group, std::vector<Path>& pathLayers);
962     DrawingHMSymbolData symbol_;
963     Point locate_;
964 };
965 
966 class ClipRectOpItem : public DrawOpItem {
967 public:
968     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle969         ConstructorHandle(const Rect& rect, ClipOp op, bool doAntiAlias)
970             : OpItem(DrawOpItem::CLIP_RECT_OPITEM), rect(rect), clipOp(op), doAntiAlias(doAntiAlias) {}
971         ~ConstructorHandle() override = default;
972         Rect rect;
973         ClipOp clipOp;
974         bool doAntiAlias;
975     };
976     explicit ClipRectOpItem(ConstructorHandle* handle);
ClipRectOpItem(const Rect & rect,ClipOp op,bool doAntiAlias)977     ClipRectOpItem(const Rect& rect, ClipOp op, bool doAntiAlias)
978         : DrawOpItem(DrawOpItem::CLIP_RECT_OPITEM), rect_(rect), clipOp_(op), doAntiAlias_(doAntiAlias) {}
979     ~ClipRectOpItem() override = default;
980 
981     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
982     void Marshalling(DrawCmdList& cmdList) override;
983     void Playback(Canvas* canvas, const Rect* rect) override;
984     void Dump(std::string& out) const override;
985 private:
986     Rect rect_;
987     ClipOp clipOp_;
988     bool doAntiAlias_;
989 };
990 
991 class ClipIRectOpItem : public DrawOpItem {
992 public:
993     struct ConstructorHandle : public OpItem {
994         ConstructorHandle(const RectI& rect, ClipOp op = ClipOp::INTERSECT)
OpItemConstructorHandle995             : OpItem(DrawOpItem::CLIP_IRECT_OPITEM), rect(rect), clipOp(op) {}
996         ~ConstructorHandle() override = default;
997         RectI rect;
998         ClipOp clipOp;
999     };
1000     explicit ClipIRectOpItem(ConstructorHandle* handle);
ClipIRectOpItem(const RectI & rect,ClipOp op)1001     ClipIRectOpItem(const RectI& rect, ClipOp op)
1002         : DrawOpItem(DrawOpItem::CLIP_IRECT_OPITEM), rect_(rect), clipOp_(op) {}
1003     ~ClipIRectOpItem() override = default;
1004 
1005     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1006     void Marshalling(DrawCmdList& cmdList) override;
1007     void Playback(Canvas* canvas, const Rect* rect) override;
1008     void Dump(std::string& out) const override;
1009 private:
1010     RectI rect_;
1011     ClipOp clipOp_;
1012 };
1013 
1014 class ClipRoundRectOpItem : public DrawOpItem {
1015 public:
1016     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1017         ConstructorHandle(const RoundRect& rrect, ClipOp op, bool doAntiAlias)
1018             : OpItem(DrawOpItem::CLIP_ROUND_RECT_OPITEM), rrect(rrect), clipOp(op), doAntiAlias(doAntiAlias) {}
1019         ~ConstructorHandle() override = default;
1020         RoundRect rrect;
1021         ClipOp clipOp;
1022         bool doAntiAlias;
1023     };
1024     explicit ClipRoundRectOpItem(ConstructorHandle* handle);
ClipRoundRectOpItem(const RoundRect & roundRect,ClipOp op,bool doAntiAlias)1025     ClipRoundRectOpItem(const RoundRect& roundRect, ClipOp op, bool doAntiAlias)
1026         : DrawOpItem(DrawOpItem::CLIP_ROUND_RECT_OPITEM), rrect_(roundRect), clipOp_(op), doAntiAlias_(doAntiAlias) {}
1027     ~ClipRoundRectOpItem() override = default;
1028 
1029     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1030     void Marshalling(DrawCmdList& cmdList) override;
1031     void Playback(Canvas* canvas, const Rect* rect) override;
1032     void Dump(std::string& out) const override;
1033 private:
1034     RoundRect rrect_;
1035     ClipOp clipOp_;
1036     bool doAntiAlias_;
1037 };
1038 
1039 class ClipPathOpItem : public DrawOpItem {
1040 public:
1041     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1042         ConstructorHandle(const OpDataHandle& path, ClipOp clipOp, bool doAntiAlias)
1043             : OpItem(DrawOpItem::CLIP_PATH_OPITEM), path(path), clipOp(clipOp), doAntiAlias(doAntiAlias) {}
1044         ~ConstructorHandle() override = default;
1045         OpDataHandle path;
1046         ClipOp clipOp;
1047         bool doAntiAlias;
1048     };
1049     ClipPathOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
ClipPathOpItem(const Path & path,ClipOp op,bool doAntiAlias)1050     ClipPathOpItem(const Path& path, ClipOp op, bool doAntiAlias)
1051         : DrawOpItem(DrawOpItem::CLIP_PATH_OPITEM), clipOp_(op), doAntiAlias_(doAntiAlias),
1052           path_(std::make_shared<Path>(path)) {}
1053     ~ClipPathOpItem() override = default;
1054 
1055     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1056     void Marshalling(DrawCmdList& cmdList) override;
1057     void Playback(Canvas* canvas, const Rect* rect) override;
1058 private:
1059     ClipOp clipOp_;
1060     bool doAntiAlias_;
1061     std::shared_ptr<Path> path_;
1062 };
1063 
1064 class ClipRegionOpItem : public DrawOpItem {
1065 public:
1066     struct ConstructorHandle : public OpItem {
1067         ConstructorHandle(const OpDataHandle& region, ClipOp clipOp = ClipOp::INTERSECT)
OpItemConstructorHandle1068             : OpItem(DrawOpItem::CLIP_REGION_OPITEM), region(region), clipOp(clipOp) {}
1069         ~ConstructorHandle() override = default;
1070         OpDataHandle region;
1071         ClipOp clipOp;
1072     };
1073     ClipRegionOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
ClipRegionOpItem(const Region & region,ClipOp op)1074     ClipRegionOpItem(const Region& region, ClipOp op)
1075         : DrawOpItem(DrawOpItem::CLIP_REGION_OPITEM), clipOp_(op), region_(std::make_shared<Region>(region)) {}
1076     ~ClipRegionOpItem() override = default;
1077 
1078     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1079     void Marshalling(DrawCmdList& cmdList) override;
1080     void Playback(Canvas* canvas, const Rect* rect) override;
1081     void Dump(std::string& out) const override;
1082 private:
1083     ClipOp clipOp_;
1084     std::shared_ptr<Region> region_;
1085 };
1086 
1087 class SetMatrixOpItem : public DrawOpItem {
1088 public:
1089     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1090         ConstructorHandle(const Matrix::Buffer& matrixBuffer)
1091             : OpItem(DrawOpItem::SET_MATRIX_OPITEM), matrixBuffer(matrixBuffer) {}
1092         ~ConstructorHandle() override = default;
1093         Matrix::Buffer matrixBuffer;
1094     };
1095     explicit SetMatrixOpItem(ConstructorHandle* handle);
SetMatrixOpItem(const Matrix & matrix)1096     explicit SetMatrixOpItem(const Matrix& matrix) : DrawOpItem(DrawOpItem::SET_MATRIX_OPITEM), matrix_(matrix) {}
1097     ~SetMatrixOpItem() override = default;
1098 
1099     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1100     void Marshalling(DrawCmdList& cmdList) override;
1101     void Playback(Canvas* canvas, const Rect* rect) override;
1102     void Dump(std::string& out) const override;
1103 private:
1104     Matrix matrix_;
1105 };
1106 
1107 class ResetMatrixOpItem : public DrawOpItem {
1108 public:
1109     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1110         ConstructorHandle() : OpItem(DrawOpItem::RESET_MATRIX_OPITEM) {}
1111         ~ConstructorHandle() override = default;
1112     };
1113     ResetMatrixOpItem();
1114     ~ResetMatrixOpItem() override = default;
1115 
1116     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1117     void Marshalling(DrawCmdList& cmdList) override;
1118     void Playback(Canvas* canvas, const Rect* rect) override;
1119 };
1120 
1121 class ConcatMatrixOpItem : public DrawOpItem {
1122 public:
1123     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1124         ConstructorHandle(const Matrix::Buffer& matrixBuffer)
1125             : OpItem(DrawOpItem::CONCAT_MATRIX_OPITEM), matrixBuffer(matrixBuffer) {}
1126         ~ConstructorHandle() override = default;
1127         Matrix::Buffer matrixBuffer;
1128     };
1129     explicit ConcatMatrixOpItem(ConstructorHandle* handle);
ConcatMatrixOpItem(const Matrix & matrix)1130     explicit ConcatMatrixOpItem(const Matrix& matrix) : DrawOpItem(DrawOpItem::CONCAT_MATRIX_OPITEM), matrix_(matrix) {}
1131     ~ConcatMatrixOpItem() override = default;
1132 
1133     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1134     void Marshalling(DrawCmdList& cmdList) override;
1135     void Playback(Canvas* canvas, const Rect* rect) override;
1136     void Dump(std::string& out) const override;
1137 private:
1138     Matrix matrix_;
1139 };
1140 
1141 class TranslateOpItem : public DrawOpItem {
1142 public:
1143     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1144         ConstructorHandle(scalar dx, scalar dy) : OpItem(DrawOpItem::TRANSLATE_OPITEM), dx(dx), dy(dy) {}
1145         ~ConstructorHandle() override = default;
1146         scalar dx;
1147         scalar dy;
1148     };
1149     explicit TranslateOpItem(ConstructorHandle* handle);
TranslateOpItem(scalar dx,scalar dy)1150     TranslateOpItem(scalar dx, scalar dy) : DrawOpItem(DrawOpItem::TRANSLATE_OPITEM), dx_(dx), dy_(dy) {}
1151     ~TranslateOpItem() override = default;
1152 
1153     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1154     void Marshalling(DrawCmdList& cmdList) override;
1155     void Playback(Canvas* canvas, const Rect* rect) override;
1156     void Dump(std::string& out) const override;
1157 private:
1158     scalar dx_;
1159     scalar dy_;
1160 };
1161 
1162 class ScaleOpItem : public DrawOpItem {
1163 public:
1164     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1165         ConstructorHandle(scalar sx, scalar sy) : OpItem(DrawOpItem::SCALE_OPITEM), sx(sx), sy(sy) {}
1166         ~ConstructorHandle() override = default;
1167         scalar sx;
1168         scalar sy;
1169     };
1170     explicit ScaleOpItem(ConstructorHandle* handle);
ScaleOpItem(scalar sx,scalar sy)1171     ScaleOpItem(scalar sx, scalar sy) : DrawOpItem(DrawOpItem::SCALE_OPITEM), sx_(sx), sy_(sy) {}
1172     ~ScaleOpItem() override = default;
1173 
1174     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1175     void Marshalling(DrawCmdList& cmdList) override;
1176     void Playback(Canvas* canvas, const Rect* rect) override;
1177     void Dump(std::string& out) const override;
1178 private:
1179     scalar sx_;
1180     scalar sy_;
1181 };
1182 
1183 class RotateOpItem : public DrawOpItem {
1184 public:
1185     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1186         ConstructorHandle(scalar deg, scalar sx, scalar sy)
1187             : OpItem(DrawOpItem::ROTATE_OPITEM), deg(deg), sx(sx), sy(sy) {}
1188         ~ConstructorHandle() override = default;
1189         scalar deg;
1190         scalar sx;
1191         scalar sy;
1192     };
1193     explicit RotateOpItem(ConstructorHandle* handle);
RotateOpItem(scalar deg,scalar sx,scalar sy)1194     RotateOpItem(scalar deg, scalar sx, scalar sy)
1195         : DrawOpItem(DrawOpItem::ROTATE_OPITEM), deg_(deg), sx_(sx), sy_(sy) {}
1196     ~RotateOpItem() override = default;
1197 
1198     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1199     void Marshalling(DrawCmdList& cmdList) override;
1200     void Playback(Canvas* canvas, const Rect* rect) override;
1201     void Dump(std::string& out) const override;
1202 private:
1203     scalar deg_;
1204     scalar sx_;
1205     scalar sy_;
1206 };
1207 
1208 class ShearOpItem : public DrawOpItem {
1209 public:
1210     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1211         ConstructorHandle(scalar sx, scalar sy) : OpItem(DrawOpItem::SHEAR_OPITEM), sx(sx), sy(sy) {}
1212         ~ConstructorHandle() override = default;
1213         scalar sx;
1214         scalar sy;
1215     };
1216     explicit ShearOpItem(ConstructorHandle* handle);
ShearOpItem(scalar sx,scalar sy)1217     ShearOpItem(scalar sx, scalar sy) : DrawOpItem(DrawOpItem::SHEAR_OPITEM), sx_(sx), sy_(sy) {}
1218     ~ShearOpItem() override = default;
1219 
1220     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1221     void Marshalling(DrawCmdList& cmdList) override;
1222     void Playback(Canvas* canvas, const Rect* rect) override;
1223     void Dump(std::string& out) const override;
1224 private:
1225     scalar sx_;
1226     scalar sy_;
1227 };
1228 
1229 class FlushOpItem : public DrawOpItem {
1230 public:
1231     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1232         ConstructorHandle() : OpItem(DrawOpItem::FLUSH_OPITEM) {}
1233         ~ConstructorHandle() override = default;
1234     };
1235     FlushOpItem();
1236     ~FlushOpItem() override = default;
1237     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1238     void Marshalling(DrawCmdList& cmdList) override;
1239     void Playback(Canvas* canvas, const Rect* rect) override;
1240 };
1241 
1242 class ClearOpItem : public DrawOpItem {
1243 public:
1244     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1245         ConstructorHandle(ColorQuad color) : OpItem(DrawOpItem::CLEAR_OPITEM), color(color) {}
1246         ~ConstructorHandle() override = default;
1247         ColorQuad color;
1248     };
1249     explicit ClearOpItem(ConstructorHandle* handle);
ClearOpItem(ColorQuad color)1250     explicit ClearOpItem(ColorQuad color) : DrawOpItem(DrawOpItem::CLEAR_OPITEM), color_(color) {}
1251     ~ClearOpItem() override = default;
1252     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1253     void Marshalling(DrawCmdList& cmdList) override;
1254     void Playback(Canvas* canvas, const Rect* rect) override;
1255     void Dump(std::string& out) const override;
1256 private:
1257     ColorQuad color_;
1258 };
1259 
1260 class SaveOpItem : public DrawOpItem {
1261 public:
1262     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1263         ConstructorHandle() : OpItem(DrawOpItem::SAVE_OPITEM) {}
1264         ~ConstructorHandle() override = default;
1265     };
1266     SaveOpItem();
1267     ~SaveOpItem() override = default;
1268     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1269     void Marshalling(DrawCmdList& cmdList) override;
1270     void Playback(Canvas* canvas, const Rect* rect) override;
1271 };
1272 
1273 class SaveLayerOpItem : public DrawOpItem {
1274 public:
1275     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1276         ConstructorHandle(const Rect& rect, bool hasBrush, const BrushHandle& brushHandle, uint32_t saveLayerFlags)
1277             : OpItem(DrawOpItem::SAVE_LAYER_OPITEM), rect(rect), hasBrush(hasBrush), brushHandle(brushHandle),
1278               saveLayerFlags(saveLayerFlags) {}
1279         ~ConstructorHandle() override = default;
1280         Rect rect;
1281         bool hasBrush;
1282         BrushHandle brushHandle;
1283         uint32_t saveLayerFlags;
1284     };
1285     SaveLayerOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
SaveLayerOpItem(const SaveLayerOps & saveLayerOps)1286     SaveLayerOpItem(const SaveLayerOps& saveLayerOps)
1287         : DrawOpItem(DrawOpItem::SAVE_LAYER_OPITEM), saveLayerFlags_(saveLayerOps.GetSaveLayerFlags())
1288     {
1289         if (saveLayerOps.GetBounds() != nullptr) {
1290             rect_ = *saveLayerOps.GetBounds();
1291         }
1292         const Brush* brush = saveLayerOps.GetBrush();
1293         if (brush != nullptr) {
1294             hasBrush_ = true;
1295             brush_ = *brush;
1296         }
1297     }
1298     ~SaveLayerOpItem() override = default;
1299 
1300     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1301     void Marshalling(DrawCmdList& cmdList) override;
1302     void Playback(Canvas* canvas, const Rect* rect) override;
1303     void Dump(std::string& out) const override;
1304 private:
1305     uint32_t saveLayerFlags_;
1306     Rect rect_;
1307     bool hasBrush_ = false;
1308     Brush brush_;
1309 };
1310 
1311 class RestoreOpItem : public DrawOpItem {
1312 public:
1313     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1314         ConstructorHandle() : OpItem(DrawOpItem::RESTORE_OPITEM) {}
1315         ~ConstructorHandle() override = default;
1316     };
1317     RestoreOpItem();
1318     ~RestoreOpItem() override = default;
1319     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1320     void Marshalling(DrawCmdList& cmdList) override;
1321     void Playback(Canvas* canvas, const Rect* rect) override;
1322 };
1323 
1324 class DiscardOpItem : public DrawOpItem {
1325 public:
1326     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1327         ConstructorHandle() : OpItem(DrawOpItem::DISCARD_OPITEM) {}
1328         ~ConstructorHandle() override = default;
1329     };
1330     DiscardOpItem();
1331     ~DiscardOpItem() override = default;
1332     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1333     void Marshalling(DrawCmdList& cmdList) override;
1334     void Playback(Canvas* canvas, const Rect* rect) override;
1335 };
1336 
1337 class ClipAdaptiveRoundRectOpItem : public DrawOpItem {
1338 public:
1339     struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1340         ConstructorHandle(const std::pair<size_t, size_t>& radiusData)
1341             : OpItem(DrawOpItem::CLIP_ADAPTIVE_ROUND_RECT_OPITEM), radiusData(radiusData) {}
1342         ~ConstructorHandle() override = default;
1343         std::pair<size_t, size_t> radiusData;
1344     };
1345     ClipAdaptiveRoundRectOpItem(const DrawCmdList& cmdList, ConstructorHandle* handle);
ClipAdaptiveRoundRectOpItem(const std::vector<Point> & radiusData)1346     explicit ClipAdaptiveRoundRectOpItem(const std::vector<Point>& radiusData)
1347         : DrawOpItem(DrawOpItem::CLIP_ADAPTIVE_ROUND_RECT_OPITEM),  radiusData_(radiusData) {}
1348     ~ClipAdaptiveRoundRectOpItem() override = default;
1349     static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1350     void Marshalling(DrawCmdList& cmdList) override;
1351     void Playback(Canvas* canvas, const Rect* rect) override;
1352     void Dump(std::string& out) const override;
1353 private:
1354     std::vector<Point> radiusData_;
1355 };
1356 
1357 class HybridRenderPixelMapSizeOpItem : public DrawOpItem {
1358     public:
1359         struct ConstructorHandle : public OpItem {
ConstructorHandleConstructorHandle1360             ConstructorHandle(float width, float height)
1361                 : OpItem(DrawOpItem::HYBRID_RENDER_PIXELMAP_SIZE_OPITEM), width(width), height(height) {}
1362             ~ConstructorHandle() override = default;
1363             float width;
1364             float height;
1365         };
1366         explicit HybridRenderPixelMapSizeOpItem(ConstructorHandle* handle);
HybridRenderPixelMapSizeOpItem(float width,float height)1367         explicit HybridRenderPixelMapSizeOpItem(float width, float height)
1368             : DrawOpItem(DrawOpItem::HYBRID_RENDER_PIXELMAP_SIZE_OPITEM), width_(width), height_(height) {}
1369         ~HybridRenderPixelMapSizeOpItem() override = default;
1370         static std::shared_ptr<DrawOpItem> Unmarshalling(const DrawCmdList& cmdList, void* handle);
1371         void Marshalling(DrawCmdList& cmdList) override;
1372         void Playback(Canvas* canvas, const Rect* rect) override;
1373         void Dump(std::string& out) const override;
1374         float GetWidth() const;
1375         float GetHeight() const;
1376     private:
1377         float width_;
1378         float height_;
1379     };
1380 } // namespace Drawing
1381 } // namespace Rosen
1382 } // namespace OHOS
1383 #endif
1384