1/*
2 * Copyright 2006 The Android Open Source Project
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 SkCornerPathEffect_DEFINED
9#define SkCornerPathEffect_DEFINED
10
11#include "include/core/SkFlattenable.h"
12#include "include/core/SkPathEffect.h"
13
14/** \class SkCornerPathEffect
15
16 SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners
17 into various treatments (e.g. rounded corners)
18*/
19class SK_API SkCornerPathEffect : public SkPathEffect {
20public:
21 /** radius must be > 0 to have an effect. It specifies the distance from each corner
22 that should be "rounded".
23 */
24 static sk_sp<SkPathEffect> Make(SkScalar radius) {
25 return radius > 0 ? sk_sp<SkPathEffect>(new SkCornerPathEffect(radius)) : nullptr;
26 }
27
28protected:
29 ~SkCornerPathEffect() override;
30
31 explicit SkCornerPathEffect(SkScalar radius);
32 void flatten(SkWriteBuffer&) const override;
33 bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
34
35private:
36 SK_FLATTENABLE_HOOKS(SkCornerPathEffect)
37
38 SkScalar fRadius;
39
40 typedef SkPathEffect INHERITED;
41};
42
43#endif
44