blob: 999ea04810bf46888c1d8d190a8a5d19773023a2 [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 SkDiscretePathEffect_DEFINED
9#define SkDiscretePathEffect_DEFINED
10
11#include "SkPathEffect.h"
12
13/** \class SkDiscretePathEffect
14
15 This path effect chops a path into discrete segments, and randomly displaces them.
16*/
tfarina@chromium.org6806fe82012-10-12 14:41:39 +000017class SK_API SkDiscretePathEffect : public SkPathEffect {
reed@android.com8a1c16f2008-12-17 15:59:43 +000018public:
19 /** Break the path into segments of segLength length, and randomly move the endpoints
20 away from the original path by a maximum of deviation.
21 Note: works on filled or framed paths
22 */
23 SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
24
reed@google.com548a1f32012-12-18 16:12:09 +000025 virtual bool filterPath(SkPath* dst, const SkPath& src,
reed@google.com4bbdeac2013-01-24 21:03:11 +000026 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000027
djsollen@google.comba28d032012-03-26 17:57:35 +000028 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect)
reed@google.com6bac9472011-06-21 19:24:00 +000029
reed@android.com8a1c16f2008-12-17 15:59:43 +000030protected:
31 SkDiscretePathEffect(SkFlattenableReadBuffer&);
djsollen@google.com54924242012-03-29 15:18:04 +000032 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000033
34private:
35 SkScalar fSegLength, fPerterb;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000036
reed@android.com8a1c16f2008-12-17 15:59:43 +000037 typedef SkPathEffect INHERITED;
38};
39
40#endif