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 SkSVGCircle_DEFINED 9 #define SkSVGCircle_DEFINED 10 11 #include "include/core/SkPath.h" 12 #include "include/core/SkRect.h" 13 #include "include/core/SkRefCnt.h" 14 #include "include/core/SkScalar.h" 15 #include "include/private/base/SkAPI.h" 16 #include "modules/svg/include/SkSVGNode.h" 17 #include "modules/svg/include/SkSVGShape.h" 18 #include "modules/svg/include/SkSVGTypes.h" 19 20 #include <tuple> 21 22 class SkCanvas; 23 class SkPaint; 24 class SkSVGLengthContext; 25 class SkSVGRenderContext; 26 enum class SkPathFillType; 27 struct SkPoint; 28 29 class SK_API SkSVGCircle final : public SkSVGShape { 30 public: Make()31 static sk_sp<SkSVGCircle> Make() { return sk_sp<SkSVGCircle>(new SkSVGCircle()); } 32 33 SVG_ATTR(Cx, SkSVGLength, SkSVGLength(0)) 34 SVG_ATTR(Cy, SkSVGLength, SkSVGLength(0)) 35 SVG_ATTR(R , SkSVGLength, SkSVGLength(0)) 36 37 protected: 38 bool parseAndSetAttribute(const char*, const char*) override; 39 40 void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&, 41 SkPathFillType) const override; 42 43 SkPath onAsPath(const SkSVGRenderContext&) const override; 44 45 SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override; 46 47 private: 48 SkSVGCircle(); 49 50 // resolve and return the center and radius values 51 std::tuple<SkPoint, SkScalar> resolve(const SkSVGLengthContext&) const; 52 53 using INHERITED = SkSVGShape; 54 }; 55 56 #endif // SkSVGCircle_DEFINED 57