blob: 87f1e44bc1078d68d1e9cfa67d8f6919f66226f7 [file] [log] [blame]
Florin Malitab3418102020-10-15 18:10:29 -04001/*
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 SkSVGRect_DEFINED
9#define SkSVGRect_DEFINED
10
11#include "modules/svg/include/SkSVGShape.h"
12#include "modules/svg/include/SkSVGTypes.h"
13
14class SkRRect;
15
16class SkSVGRect final : public SkSVGShape {
17public:
Florin Malitab3418102020-10-15 18:10:29 -040018 static sk_sp<SkSVGRect> Make() { return sk_sp<SkSVGRect>(new SkSVGRect()); }
19
Tyler Denniston52d94752021-02-05 10:23:34 -050020 SVG_ATTR(X , SkSVGLength, SkSVGLength(0))
21 SVG_ATTR(Y , SkSVGLength, SkSVGLength(0))
22 SVG_ATTR(Width , SkSVGLength, SkSVGLength(0))
23 SVG_ATTR(Height, SkSVGLength, SkSVGLength(0))
Florin Malitac49c7f52021-03-29 13:38:38 -040024
25 SVG_OPTIONAL_ATTR(Rx, SkSVGLength)
26 SVG_OPTIONAL_ATTR(Ry, SkSVGLength)
Florin Malitab3418102020-10-15 18:10:29 -040027
28protected:
Tyler Denniston52d94752021-02-05 10:23:34 -050029 bool parseAndSetAttribute(const char*, const char*) override;
Florin Malitab3418102020-10-15 18:10:29 -040030
31 void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
32 SkPathFillType) const override;
33
34 SkPath onAsPath(const SkSVGRenderContext&) const override;
35
Tyler Dennistonf548a022020-10-27 15:02:02 -040036 SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
37
Florin Malitab3418102020-10-15 18:10:29 -040038private:
39 SkSVGRect();
40
41 SkRRect resolve(const SkSVGLengthContext&) const;
42
Florin Malitab3418102020-10-15 18:10:29 -040043 using INHERITED = SkSVGShape;
44};
45
46#endif // SkSVGRect_DEFINED