blob: 593f4bea2b050fb5e8dfd95289f602b9cfebb3f8 [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
11#include "SkPathEffect.h"
12
13/** \class SkCornerPathEffect
14
15 SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners
16 into various treatments (e.g. rounded corners)
17*/
ctguil@chromium.org7ffb1b22011-03-15 21:27:08 +000018class SK_API SkCornerPathEffect : public SkPathEffect {
reed@android.com8a1c16f2008-12-17 15:59:43 +000019public:
20 /** radius must be > 0 to have an effect. It specifies the distance from each corner
21 that should be "rounded".
22 */
reeda4393342016-03-18 11:22:57 -070023 static sk_sp<SkPathEffect> Make(SkScalar radius) {
24 return sk_sp<SkPathEffect>(new SkCornerPathEffect(radius));
25 }
26
reed@google.com548a1f32012-12-18 16:12:09 +000027 virtual bool filterPath(SkPath* dst, const SkPath& src,
mtklein36352bf2015-03-25 18:17:31 -070028 SkStrokeRec*, const SkRect*) const override;
reed@android.com8a1c16f2008-12-17 15:59:43 +000029
robertphillips42dbfa82015-01-26 06:08:52 -080030 SK_TO_STRING_OVERRIDE()
djsollen@google.comba28d032012-03-26 17:57:35 +000031 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCornerPathEffect)
reed@google.com6bac9472011-06-21 19:24:00 +000032
tomhudson64de1e12015-03-05 08:01:07 -080033#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
mtklein36352bf2015-03-25 18:17:31 -070034 bool exposedInAndroidJavaAPI() const override { return true; }
tomhudson64de1e12015-03-05 08:01:07 -080035#endif
36
reed@android.com8a1c16f2008-12-17 15:59:43 +000037protected:
reed5e1ddb12015-12-21 08:52:45 -080038 virtual ~SkCornerPathEffect();
39
commit-bot@chromium.orgbd0be252014-05-15 15:40:41 +000040 explicit SkCornerPathEffect(SkScalar radius);
mtklein36352bf2015-03-25 18:17:31 -070041 void flatten(SkWriteBuffer&) 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