xref: /aosp_15_r20/external/skia/modules/svg/include/SkSVGEllipse.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2016 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkSVGEllipse_DEFINED
9 #define SkSVGEllipse_DEFINED
10 
11 #include "include/core/SkPath.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/private/base/SkAPI.h"
14 #include "modules/svg/include/SkSVGNode.h"
15 #include "modules/svg/include/SkSVGShape.h"
16 #include "modules/svg/include/SkSVGTypes.h"
17 #include "src/base/SkTLazy.h"
18 
19 class SkCanvas;
20 class SkPaint;
21 class SkSVGLengthContext;
22 class SkSVGRenderContext;
23 enum class SkPathFillType;
24 struct SkRect;
25 
26 class SK_API SkSVGEllipse final : public SkSVGShape {
27 public:
Make()28     static sk_sp<SkSVGEllipse> Make() { return sk_sp<SkSVGEllipse>(new SkSVGEllipse()); }
29 
30     SVG_ATTR(Cx, SkSVGLength, SkSVGLength(0))
31     SVG_ATTR(Cy, SkSVGLength, SkSVGLength(0))
32 
33     SVG_OPTIONAL_ATTR(Rx, SkSVGLength)
34     SVG_OPTIONAL_ATTR(Ry, SkSVGLength)
35 
36 protected:
37     bool parseAndSetAttribute(const char*, const char*) override;
38 
39     void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
40                 SkPathFillType) const override;
41 
42     SkPath onAsPath(const SkSVGRenderContext&) const override;
43 
44 private:
45     SkSVGEllipse();
46 
47     SkRect resolve(const SkSVGLengthContext&) const;
48 
49     using INHERITED = SkSVGShape;
50 };
51 
52 #endif // SkSVGEllipse_DEFINED
53