blob: f35f32e790a3dda05e4352efcc7a27cd7a6c049c [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2006 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00003 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00006 */
7
8#ifndef SkCornerPathEffect_DEFINED
9#define SkCornerPathEffect_DEFINED
10
Cary Clark4dc5a452018-05-21 11:56:57 -040011#include "SkFlattenable.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000012#include "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*/
ctguil@chromium.org7ffb1b22011-03-15 21:27:08 +000019class SK_API SkCornerPathEffect : public SkPathEffect {
reed@android.com8a1c16f2008-12-17 15:59:43 +000020public:
21 /** radius must be > 0 to have an effect. It specifies the distance from each corner
22 that should be "rounded".
23 */
reeda4393342016-03-18 11:22:57 -070024 static sk_sp<SkPathEffect> Make(SkScalar radius) {
Florin Malita41dff6e2018-04-30 23:08:15 -040025 return radius > 0 ? sk_sp<SkPathEffect>(new SkCornerPathEffect(radius)) : nullptr;
reeda4393342016-03-18 11:22:57 -070026 }
27
Cary Clark4dc5a452018-05-21 11:56:57 -040028 Factory getFactory() const override { return CreateProc; }
reed@google.com6bac9472011-06-21 19:24:00 +000029
tomhudson64de1e12015-03-05 08:01:07 -080030#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
mtklein36352bf2015-03-25 18:17:31 -070031 bool exposedInAndroidJavaAPI() const override { return true; }
tomhudson64de1e12015-03-05 08:01:07 -080032#endif
33
reed@android.com8a1c16f2008-12-17 15:59:43 +000034protected:
Brian Salomond3b65972017-03-22 12:05:03 -040035 ~SkCornerPathEffect() override;
Cary Clark4dc5a452018-05-21 11:56:57 -040036 static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
37 friend class SkFlattenable::PrivateInitializer;
reed5e1ddb12015-12-21 08:52:45 -080038
commit-bot@chromium.orgbd0be252014-05-15 15:40:41 +000039 explicit SkCornerPathEffect(SkScalar radius);
mtklein36352bf2015-03-25 18:17:31 -070040 void flatten(SkWriteBuffer&) const override;
Mike Reed6d10f8b2018-08-16 13:22:16 -040041 bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
reed@android.com8a1c16f2008-12-17 15:59:43 +000042
43private:
44 SkScalar fRadius;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000045
reed@android.com8a1c16f2008-12-17 15:59:43 +000046 typedef SkPathEffect INHERITED;
47};
48
49#endif