1 /*
2  * Copyright (c) 2020-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 /**
17  * @addtogroup UI_Components
18  * @{
19  *
20  * @brief Defines UI components such as buttons, texts, images, lists, and progress bars.
21  *
22  * @since 1.0
23  * @version 1.0
24  */
25 
26 /**
27  * @file ui_canvas.h
28  *
29  * @brief Defines the attributes of the canvas component and provides functions for drawing rectangles,
30  *        circles, and others.
31  *
32  * @since 1.0
33  * @version 1.0
34  */
35 
36 #ifndef GRAPHIC_LITE_UI_CANVAS_H
37 #define GRAPHIC_LITE_UI_CANVAS_H
38 
39 #include "common/image.h"
40 #include "components/ui_label.h"
41 #include "gfx_utils/diagram/depiction/depict_curve.h"
42 #include "gfx_utils/diagram/depiction/depict_dash.h"
43 #include "gfx_utils/diagram/depiction/depict_stroke.h"
44 #include "gfx_utils/diagram/imagefilter/filter_blur.h"
45 #include "gfx_utils/diagram/rasterizer/rasterizer_scanline_antialias.h"
46 #include "gfx_utils/diagram/scanline/geometry_scanline.h"
47 #include "gfx_utils/diagram/spancolorfill/fill_base.h"
48 #include "gfx_utils/diagram/spancolorfill/fill_gradient.h"
49 #include "gfx_utils/diagram/spancolorfill/fill_gradient_lut.h"
50 #include "gfx_utils/diagram/spancolorfill/fill_interpolator.h"
51 #include "gfx_utils/diagram/spancolorfill/fill_pattern_rgba.h"
52 #include "gfx_utils/diagram/vertexprimitive/geometry_path_storage.h"
53 #include "ui_extend_image_view.h"
54 #include "gfx_utils/file.h"
55 #include "gfx_utils/list.h"
56 #include "gfx_utils/diagram/common/paint.h"
57 
58 namespace OHOS {
59 class RenderBase;
60 
61 /**
62  * @brief Defines a canvas, which is used to draw multiple types of 2D graphs.
63  *
64  * @since 1.0
65  * @version 1.0
66  */
67 class UICanvas : public UIView {
68 public:
69     /**
70      * @brief A constructor used to create a <b>UICanvas</b> instance.
71      *
72      * @since 1.0
73      * @version 1.0
74      */
UICanvas()75     UICanvas() : startPoint_({0, 0}), vertices_(nullptr), path_(nullptr) {}
76 
77     /**
78      * @brief A destructor used to delete the <b>UICanvas</b> instance.
79      *
80      * @since 1.0
81      * @version 1.0
82      */
83     virtual ~UICanvas();
84 
85     /**
86      * @brief Obtains the view type.
87      *
88      * @return Returns the view type. For details, see {@link UIViewType}.
89      * @since 1.0
90      * @version 1.0
91      */
GetViewType()92     UIViewType GetViewType() const override
93     {
94         return UI_CANVAS;
95     }
96 
97     /**
98      * @brief Clears the entire canvas.
99      *
100      * @since 1.0
101      * @version 1.0
102      */
103     void Clear();
104 
105     /**
106      * @brief Sets the coordinates of the start point for drawing a line. For example, if <b>startPoint</b> is
107      *        set to {50, 50}, the line is drawn from this set of coordinates on the canvas.
108      *
109      * @param startPoint Indicates the coordinates of the start point.
110      * @see GetStartPosition
111      * @since 1.0
112      * @version 1.0
113      */
SetStartPosition(const Point & startPoint)114     void SetStartPosition(const Point& startPoint)
115     {
116         startPoint_ = startPoint;
117     }
118 
119     /**
120      * @brief Obtains the coordinates of the start point of a line.
121      *
122      * @return Returns the coordinates of the start point.
123      * @see SetStartPosition
124      * @since 1.0
125      * @version 1.0
126      */
GetStartPosition()127     const Point& GetStartPosition() const
128     {
129         return startPoint_;
130     }
131 
132     /**
133      * @brief Draws a straight line.
134      *
135      * If {@link SetStartPosition} is not used to set the coordinates of the start point of the line, the drawing
136      * starts from the end point of the last line.
137      *
138      * @param endPoint Indicates the end point of the straight line.
139      * @param paint    Indicates the straight line style. For details, see {@link Paint}.
140      * @since 1.0
141      * @version 1.0
142      */
143     void DrawLine(const Point& endPoint, const Paint& paint);
144 
145     /**
146      * @brief Draws a straight line from the coordinates of the start point.
147      *
148      * @param startPoint Indicates the coordinates of the start point.
149      * @param endPoint   Indicates the coordinates of the end point.
150      * @param paint      Indicates the straight line style. For details, see {@link Paint}.
151      * @since 1.0
152      * @version 1.0
153      */
154     void DrawLine(const Point& startPoint, const Point& endPoint, const Paint& paint);
155 
156     /**
157      * @brief Draws a cubic Bezier curve.
158      *
159      * If {@link SetStartPosition} is not used to set the coordinates of the start point of the curve,
160      * the drawing starts from the end point of the last line.
161      * Currently, the opacity cannot be set, and the maximum line width is <b>3</b>.
162      *
163      * @param control1 Indicates the coordinates of the first control point of the cubic Bezier curve.
164      * @param control2 Indicates the coordinates of the second control point of the cubic Bezier curve.
165      * @param endPoint Indicates the coordinates of the end point of the cubic Bezier curve.
166      * @param paint    Indicates the curve style. For details, see {@link Paint}.
167      * @since 1.0
168      * @version 1.0
169      */
170     void DrawCurve(const Point& control1, const Point& control2, const Point& endPoint, const Paint& paint);
171 
172     /**
173      * @brief Draws a cubic Bezier curve from the start point coordinates.
174      *
175      * Currently, the opacity cannot be set, and the maximum line width is <b>3</b>.
176      *
177      * @param startPoint Indicates the coordinates of the start point of the cubic Bezier curve.
178      * @param control1   Indicates the coordinates of the first control point of the cubic Bezier curve.
179      * @param control2   Indicates the coordinates of the second control point of the cubic Bezier curve.
180      * @param endPoint   Indicates the coordinates of the end point of the cubic Bezier curve.
181      * @param paint      Indicates the curve style. For details, see {@link Paint}.
182      * @since 1.0
183      * @version 1.0
184      */
185     void DrawCurve(const Point& startPoint, const Point& control1, const Point& control2,
186                    const Point& endPoint, const Paint& paint);
187 
188     /**
189      * @brief Draws a rectangle.
190      *
191      * @param startPoint Indicates the coordinates of the point at the upper left corner of the rectangle.
192      * @param height     Indicates the height of the rectangle.
193      * @param width      Indicates the width of the rectangle.
194      * @param paint      Indicates the rectangle style. For details, see {@link Paint}.
195      * @since 1.0
196      * @version 1.0
197      */
198     void DrawRect(const Point& startPoint, int16_t height, int16_t width, const Paint& paint);
199 
200 #if defined(ENABLE_CANVAS_EXTEND) && ENABLE_CANVAS_EXTEND
201     /**
202      * @brief Draws a rectangular path with no fill.
203      * @param startPoint starting point
204      * @param height
205      * @param width
206      * @param paint paint brush
207      */
208     void StrokeRect(const Point& startPoint, int16_t height, int16_t width, const Paint& paint);
209 
210     /**
211      * @brief Clears pixels within a rectangle
212      * @param startPoint starting point
213      * @param height
214      * @param width
215      */
216     void ClearRect(const Point& startPoint, int16_t height, int16_t width);
217 #endif
218 
219     /**
220      * @brief Draws a circle.
221      *
222      * @param center Indicates the coordinates of the circle center.
223      * @param radius Indicates the radius of the circle.
224      * @param paint  Indicates the circle style. For details, see {@link Paint}.
225      * @since 1.0
226      * @version 1.0
227      */
228     void DrawCircle(const Point& center, uint16_t radius, const Paint& paint);
229 
230     /**
231      * @brief Draws a sector.
232      *
233      * When the start angle is smaller than the end angle, the sector is drawn clockwise.
234      * Otherwise, the sector is drawn counterclockwise.
235      *
236      * @param center     Indicates the coordinates of the sector's center.
237      * @param radius     Indicates the radius of the sector.
238      * @param startAngle Indicates the start angle of the sector. Value <b>0</b> indicates the 12-o'clock direction,
239      *                   and <b>90</b> indicates the 3-o'clock direction.
240      * @param endAngle   Indicates the end angle of the sector. Value <b>0</b> indicates the 12-o'clock direction,
241      *                   and <b>90</b> indicates the 3-o'clock direction.
242      * @param paint      Indicates the sector style. For details, see {@link Paint}.
243      * @since 1.0
244      * @version 1.0
245      */
246     void DrawSector(const Point& center, uint16_t radius, int16_t startAngle, int16_t endAngle, const Paint& paint);
247 
248     /**
249      * @brief Draws an arc.
250      *
251      * Only stroke is supported. \n
252      * When the start angle is smaller than the end angle, the sector is drawn clockwise.
253      * Otherwise, the sector is drawn counterclockwise. \n
254     *
255      * @param center     Indicates the coordinates of the arc's center.
256      * @param radius     Indicates the radius of the arc.
257      * @param startAngle Indicates the start angle of the arc. Value <b>0</b> indicates the 12-o'clock direction,
258      *                   and <b>90</b> indicates the 3-o'clock direction.
259      * @param endAngle   Indicates the end angle of the arc. Value <b>0</b> indicates the 12-o'clock direction,
260      *                   and <b>90</b> indicates the 3-o'clock direction.
261      * @param paint      Indicates the arc style. For details, see {@link Paint}.
262      * @since 1.0
263      * @version 1.0
264      */
265     void DrawArc(const Point& center, uint16_t radius, int16_t startAngle, int16_t endAngle, const Paint& paint);
266 
267 #if defined(GRAPHIC_ENABLE_DRAW_IMAGE_FLAG) && GRAPHIC_ENABLE_DRAW_IMAGE_FLAG
268     /**
269      * @brief Draws an image.
270      *
271      * @param startPoint Indicates the coordinates of the start point.
272      * @param image      Indicates the pointer to the image source.
273      * @param paint      Indicates the image style. For details, see {@link Paint}.
274      * @since 1.0
275      * @version 1.0
276      */
277     void DrawImage(const Point& startPoint, const char* image, const Paint& paint);
278 
279     void DrawImage(const Point& startPoint, const char* image, const Paint& paint, int16_t width, int16_t height);
280 #endif
281     /**
282      * @brief Defines the font style.
283      */
284     struct FontStyle : public HeapBase {
285         /** Text direction. For details, see {@link UITextLanguageDirect}. */
286         UITextLanguageDirect direct;
287         /** Text alignment mode. For details, see {@link UITextLanguageAlignment}. */
288         UITextLanguageAlignment align;
289         /** Font size */
290         uint8_t fontSize;
291         /** Letter-spacing */
292         int16_t letterSpace;
293         /** Font name */
294         const char* fontName;
295     };
296 
297     struct DrawCmd : public HeapBase {
298         Paint paint;
299         void* param;
300         void (*DrawGraphics)(BufferInfo&, void*, const Paint&, const Rect&, const Rect&, const Style&);
301         void (*DeleteParam)(void*);
302     };
303 
304     /**
305      * @brief Draws text.
306      *
307      * Only fill is supported. \n
308      * If the text length exceeds the value of <b>maxWidth</b>, the text will be truncated. \n
309      *
310      * @param startPoint Indicates the coordinates of the start point.
311      * @param text       Indicates the pointer to the text content.
312      * @param maxWidth   Indicates the maximum width of the text that can be displayed. If the maximum width is
313      *                   exceeded, the text is truncated.
314      * @param fontStyle  Indicates the text layout and font style. For details, see {@link FontStyle}.
315      * @param paint      Indicates the text style. For details, see {@link Paint}.
316      * @since 1.0
317      * @version 1.0
318      */
319     void DrawLabel(const Point& startPoint, const char* text, uint16_t maxWidth, const FontStyle& fontStyle,
320                    const Paint& paint);
321 
322     /**
323      * @brief Creates a path.
324      *
325      * A round corner can be used to join two lines. Currently, miter and bevel joints are not supported.
326      * To draw this path, you need to call {@link DrawPath}.
327      *
328      * @since 3.0
329      * @version 5.0
330      */
331     void BeginPath();
332 
333     /**
334      * @brief Moves the start point of this path to a specified point.
335      *
336      * @param point Indicates the specified point to move to.
337      * @since 3.0
338      * @version 5.0
339      */
340     void MoveTo(const Point& point);
341 
342     /**
343      * @brief Creates a straight line from the end point of this path to a specified point.
344      *
345      * @param point Indicates the coordinates of the specified point.
346      * @since 3.0
347      * @version 5.0
348      */
349     void LineTo(const Point& point);
350 
351     /**
352      * @brief Creates an arc path.
353      *
354      * @param center     Indicates the coordinates of the arc's center point.
355      * @param radius     Indicates the radius of the arc.
356      * @param startAngle Indicates the start angle of the arc.
357      *                   The value <b>0</b> indicates the 12-o'clock direction,
358      *                   and <b>90</b> indicates the 3-o'clock direction.
359      * @param endAngle   Indicates the end angle of the arc.
360      *                   The value <b>0</b> indicates the 12-o'clock direction,
361      *                   and <b>90</b> indicates the 3-o'clock direction.
362      * @since 3.0
363      * @version 5.0
364      */
365     void ArcTo(const Point& center, uint16_t radius, int16_t startAngle, int16_t endAngle);
366 
367     /**
368      * @brief Creates a rectangular path.
369      *
370      * @param point  Indicates the coordinates of the rectangle's upper left corner.
371      * @param height Indicates the height of the rectangle.
372      * @param width  Indicates the width of the rectangle.
373      * @since 3.0
374      * @version 5.0
375      */
376     void AddRect(const Point& point, int16_t height, int16_t width);
377 
378     /**
379      * @brief Closes this path.
380      *
381      * @since 3.0
382      * @version 5.0
383      */
384     void ClosePath();
385 
386     /**
387      * @brief Draws this path.
388      *
389      * @param paint Indicates the path style. For details, see {@link Paint}.
390      * @since 3.0
391      * @version 5.0
392      */
393     void DrawPath(const Paint& paint);
394 
395 #if defined(ENABLE_CANVAS_EXTEND) && ENABLE_CANVAS_EXTEND
396     /**
397      * @brief Fill polygon path
398      * @param paint fill paint
399      * @since 3.0
400      * @version 5.0
401      */
402     void FillPath(const Paint& paint);
403 #endif
404 
405 #if defined(GRAPHIC_ENABLE_DRAW_TEXT_FLAG) && GRAPHIC_ENABLE_DRAW_TEXT_FLAG
406     /*  Draw text on canvas */
407     void StrokeText(const char* text, const Point& point, const FontStyle& fontStyle, const Paint& paint);
408 #endif
409 
410     /* Returns an object containing the specified text width */
411     Point MeasureText(const char* text, const FontStyle& fontStyle);
412 
413     /* Save history status */
Save(Paint paint)414     void Save(Paint paint)
415     {
416         paintStack_.PushBack(paint);
417     }
418 
419     /**
420      * @brief Restore to last historical state
421      * @return Returns the last paint value.
422      * @since 3.0
423      * @version 5.0
424      */
Restore()425     Paint Restore()
426     {
427         Paint paint;
428         if (paintStack_.IsEmpty()) {
429             return paint;
430         }
431         paint = paintStack_.Back();
432         paintStack_.PopBack();
433         return paint;
434     }
435 
436 #if defined(ENABLE_CANVAS_EXTEND) && ENABLE_CANVAS_EXTEND
437     void OnBlendDraw(BufferInfo& gfxDstBuffer, const Rect& trunc);
438 #endif
439 
440     void OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea) override;
441 
442     static void BlendRaster(const Paint& paint,
443                         void* param,
444                         RasterizerScanlineAntialias& blendRasterizer,
445                         RasterizerScanlineAntialias& rasterizer,
446                         RenderBase& renBase,
447                         TransAffine& transform,
448                         SpanBase& spanGen,
449                         const Rect& rect,
450                         bool isStroke);
451     static void DeleteImageParam(void* param);
452     static void DeletePathParam(void* param);
453 protected:
454     constexpr static uint8_t MAX_CURVE_WIDTH = 3;
455 
456     struct LineParam : public HeapBase {
457         Point start;
458         Point end;
459     };
460 
461     struct CurveParam : public HeapBase {
462         Point start;
463         Point control1;
464         Point control2;
465         Point end;
466     };
467 
468     struct RectParam : public HeapBase {
469         Point start;
470         int16_t height;
471         int16_t width;
472     };
473 
474     struct CircleParam : public HeapBase {
475         Point center;
476         uint16_t radius;
477     };
478 
479     struct ArcParam : public HeapBase {
480         Point center;
481         uint16_t radius;
482         int16_t startAngle;
483         int16_t endAngle;
484     };
485 
486     enum PathCmd {
487         CMD_MOVE_TO,
488         CMD_LINE_TO,
489         CMD_ARC,
490         CMD_CLOSE,
491     };
492 
493     class UICanvasPath : public HeapBase {
494     public:
UICanvasPath()495         UICanvasPath() : startPos_({ 0, 0 }), strokeCount_(0) {};
496         ~UICanvasPath();
497         List<Point> points_;
498         List<PathCmd> cmd_;
499         List<ArcParam> arcParam_;
500         Point startPos_;
501         uint16_t strokeCount_;
502     };
503 
504 #if (!(defined(ENABLE_CANVAS_EXTEND) && ENABLE_CANVAS_EXTEND))
505     struct PathParam : public HeapBase {
506         UICanvasPath* path;
507         uint16_t count;
508     };
509 
510     struct ImageParam : public HeapBase {
511         Point start;
512         uint16_t height;
513         uint16_t width;
514         Image* image;
515     };
516 #endif
517 
518     struct TextParam : public HeapBase {
519         const char* text;
520         Point position;
521         Color32 fontColor;
522         uint8_t fontOpa;
523         FontStyle fontStyle;
524         Text* textComment;
TextParamTextParam525         TextParam() : text(nullptr), position({0, 0}), fontOpa(0)
526         {
527             fontColor.full = 0;
528             fontStyle.direct = UITextLanguageDirect::TEXT_DIRECT_LTR;
529             fontStyle.align = UITextLanguageAlignment::TEXT_ALIGNMENT_LEFT;
530             fontStyle.fontSize = 0;
531             fontStyle.letterSpace = 0;
532             fontStyle.fontName = nullptr;
533             textComment = new Text;
534         }
535 
~TextParamTextParam536         ~TextParam()
537         {
538             if (textComment) {
539                 delete textComment;
540                 textComment = nullptr;
541             }
542         };
543     };
544 
545     Point startPoint_;
546     UICanvasVertices* vertices_;
547     UICanvasPath* path_;
548     List<DrawCmd> drawCmdList_;
549     // Save historical modification information of paint
550     List<Paint> paintStack_;
551     static BufferInfo* gfxMapBuffer_;
552 
DeleteLineParam(void * param)553     static void DeleteLineParam(void* param)
554     {
555         LineParam* lineParam = static_cast<LineParam*>(param);
556         delete lineParam;
557     }
558 
DeleteCurveParam(void * param)559     static void DeleteCurveParam(void* param)
560     {
561         CurveParam* curveParam = static_cast<CurveParam*>(param);
562         delete curveParam;
563     }
564 
DeleteRectParam(void * param)565     static void DeleteRectParam(void* param)
566     {
567         RectParam* rectParam = static_cast<RectParam*>(param);
568         delete rectParam;
569     }
570 
DeleteCircleParam(void * param)571     static void DeleteCircleParam(void* param)
572     {
573         CircleParam* circleParam = static_cast<CircleParam*>(param);
574         delete circleParam;
575     }
576 
DeleteArcParam(void * param)577     static void DeleteArcParam(void* param)
578     {
579         ArcParam* arcParam = static_cast<ArcParam*>(param);
580         delete arcParam;
581     }
582 
DeleteLabel(void * param)583     static void DeleteLabel(void* param)
584     {
585         UILabel* label = static_cast<UILabel*>(param);
586         delete label;
587     }
588 
DeleteImageView(void * param)589     static void DeleteImageView(void* param)
590     {
591         UIExtendImageView* imageView = static_cast<UIExtendImageView*>(param);
592         delete imageView;
593     }
594 
DeleteTextParam(void * param)595     static void DeleteTextParam(void* param)
596     {
597         TextParam* textParam = static_cast<TextParam*>(param);
598         delete textParam;
599     }
600 
601     static void DoDrawLine(BufferInfo& gfxDstBuffer,
602                            void* param,
603                            const Paint& paint,
604                            const Rect& rect,
605                            const Rect& invalidatedArea,
606                            const Style& style);
607     static void DoDrawCurve(BufferInfo& gfxDstBuffer,
608                             void* param,
609                             const Paint& paint,
610                             const Rect& rect,
611                             const Rect& invalidatedArea,
612                             const Style& style);
613     static void DoDrawRect(BufferInfo& gfxDstBuffer,
614                            void* param,
615                            const Paint& paint,
616                            const Rect& rect,
617                            const Rect& invalidatedArea,
618                            const Style& style);
619     static void DoFillRect(BufferInfo& gfxDstBuffer,
620                            void* param,
621                            const Paint& paint,
622                            const Rect& rect,
623                            const Rect& invalidatedArea,
624                            const Style& style);
625     static void DoDrawCircle(BufferInfo& gfxDstBuffer,
626                              void* param,
627                              const Paint& paint,
628                              const Rect& rect,
629                              const Rect& invalidatedArea,
630                              const Style& style);
631     static void DoDrawArc(BufferInfo& gfxDstBuffer,
632                           void* param,
633                           const Paint& paint,
634                           const Rect& rect,
635                           const Rect& invalidatedArea,
636                           const Style& style);
637 #if defined(GRAPHIC_ENABLE_DRAW_IMAGE_FLAG) && GRAPHIC_ENABLE_DRAW_IMAGE_FLAG
638     static void DoDrawImage(BufferInfo& gfxDstBuffer,
639                             void* param,
640                             const Paint& paint,
641                             const Rect& rect,
642                             const Rect& invalidatedArea,
643                             const Style& style);
644 #endif
645 
646     static void DoDrawLabel(BufferInfo& gfxDstBuffer,
647                             void* param,
648                             const Paint& paint,
649                             const Rect& rect,
650                             const Rect& invalidatedArea,
651                             const Style& style);
652     static void DoDrawPath(BufferInfo& gfxDstBuffer,
653                            void* param,
654                            const Paint& paint,
655                            const Rect& rect,
656                            const Rect& invalidatedArea,
657                            const Style& style);
658     static void GetAbsolutePosition(const Point& prePoint, const Rect& rect, const Style& style, Point& point);
659     static void DoDrawLineJoin(BufferInfo& gfxDstBuffer,
660                                const Point& center,
661                                const Rect& invalidatedArea,
662                                const Paint& paint);
663 
664     static void DoFillPath(BufferInfo& gfxDstBuffer,
665                            void* param,
666                            const Paint& paint,
667                            const Rect& rect,
668                            const Rect& invalidatedArea,
669                            const Style& style);
670 
671     static void  BlitMapBuffer(BufferInfo &gfxDstBuffer, BufferInfo& gfxMapBuffer,
672                               Rect& textRect, TransformMap& transMap, const Rect& invalidatedArea);
673 
674 #if defined(GRAPHIC_ENABLE_DRAW_TEXT_FLAG) && GRAPHIC_ENABLE_DRAW_TEXT_FLAG
675     static void DoDrawText(BufferInfo& gfxDstBuffer, void* param, const Paint& paint, const Rect& rect,
676                            const Rect& invalidatedArea, const Style& style);
677 #endif
678     /**
679      * Assembly parameter setting lineweight,LineCap,LineJoin
680      */
681     template <class LineStyle>
LineStyleCalc(DepictStroke<LineStyle> & strokeLineStyle,const Paint & paint)682     static void LineStyleCalc(DepictStroke<LineStyle>& strokeLineStyle, const Paint& paint)
683     {
684         strokeLineStyle.SetWidth(paint.GetStrokeWidth()); // Line style related
685 #if defined(GRAPHIC_ENABLE_LINECAP_FLAG) && GRAPHIC_ENABLE_LINECAP_FLAG
686         strokeLineStyle.SetLineCap(paint.GetLineCap());
687 #endif
688 #if defined(GRAPHIC_ENABLE_LINEJOIN_FLAG) && GRAPHIC_ENABLE_LINEJOIN_FLAG
689         strokeLineStyle.SetLineJoin(paint.GetLineJoin());
690         if (paint.GetMiterLimit() > 0) {
691             strokeLineStyle.SetMiterLimit(paint.GetMiterLimit());
692         }
693 #endif
694     };
695 
IsSoild(const Paint & paint)696     static bool IsSoild(const Paint& paint)
697     {
698         if (paint.GetStyle() == Paint::STROKE_STYLE ||
699            paint.GetStyle() == Paint::FILL_STYLE ||
700            paint.GetStyle() == Paint::STROKE_FILL_STYLE) {
701             return true;
702         }
703         return false;
704     }
705 
706     void DrawRectSetCmd(const Point& startPoint, int16_t height, int16_t width, const Paint& paint,
707                         Paint::PaintStyle paintStyle);
708     static void InitGfxMapBuffer(const BufferInfo& srcBuff, const Rect& rect);
709     static BufferInfo* UpdateMapBufferInfo(const BufferInfo& srcBuff, const Rect& rect);
710     static void DestroyMapBufferInfo();
711     void SetArcParamInfo(const Point& center, uint16_t radius, int16_t startAngle, int16_t endAngle);
712 #if defined(ENABLE_CANVAS_EXTEND) && ENABLE_CANVAS_EXTEND
713     void SetDrawLinePath(const Point& startPoint, int16_t height, int16_t width, const Paint& paint);
714 #endif
715 };
716 } // namespace OHOS
717 #endif // GRAPHIC_LITE_UI_CANVAS_H
718