aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg/model/SkSVGRect.h
blob: e61f2764188c134c5bf1b34e71e48073cc9372d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkSVGRect_DEFINED
#define SkSVGRect_DEFINED

#include "SkSVGShape.h"
#include "SkSVGTypes.h"

class SkRRect;

class SkSVGRect final : public SkSVGShape {
public:
    ~SkSVGRect() override = default;
    static sk_sp<SkSVGRect> Make() { return sk_sp<SkSVGRect>(new SkSVGRect()); }

    void setX(const SkSVGLength&);
    void setY(const SkSVGLength&);
    void setWidth(const SkSVGLength&);
    void setHeight(const SkSVGLength&);
    void setRx(const SkSVGLength&);
    void setRy(const SkSVGLength&);

protected:
    void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;

    void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
                SkPath::FillType) const override;

    SkPath onAsPath(const SkSVGRenderContext&) const override;

private:
    SkSVGRect();

    SkRRect resolve(const SkSVGLengthContext&) const;

    SkSVGLength fX      = SkSVGLength(0);
    SkSVGLength fY      = SkSVGLength(0);
    SkSVGLength fWidth  = SkSVGLength(0);
    SkSVGLength fHeight = SkSVGLength(0);

    // The x radius for rounded rects.
    SkSVGLength fRx     = SkSVGLength(0);
    // The y radius for rounded rects.
    SkSVGLength fRy     = SkSVGLength(0);

    typedef SkSVGShape INHERITED;
};

#endif // SkSVGRect_DEFINED