18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkDiscretePathEffect_DEFINED 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkDiscretePathEffect_DEFINED 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPathEffect.h" 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkDiscretePathEffect 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This path effect chops a path into discrete segments, and randomly displaces them. 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 176806fe87e0b39e283291c1a1c7d1d864230aa2aatfarina@chromium.orgclass SK_API SkDiscretePathEffect : public SkPathEffect { 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Break the path into segments of segLength length, and randomly move the endpoints 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com away from the original path by a maximum of deviation. 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Note: works on filled or framed paths 2239e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja 2339e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja @param seedAssist This is a caller-supplied seedAssist that modifies 2439e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja the seed value that is used to randomize the path 2539e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja segments' endpoints. If not supplied it defaults to 0, 2639e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja in which case filtering a path multiple times will 2739e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja result in the same set of segments (this is useful for 2839e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja testing). If a caller does not want this behaviour 2939e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja they can pass in a different seedAssist to get a 3039e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja different set of path segments. 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3239e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja static SkDiscretePathEffect* Create(SkScalar segLength, 3339e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja SkScalar deviation, 3439e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja uint32_t seedAssist=0) { 3539e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja return SkNEW_ARGS(SkDiscretePathEffect, 3639e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja (segLength, deviation, seedAssist)); 370a2bf90dccba3bde188e0386a7f0c60e6dde1ae9commit-bot@chromium.org } 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 39548a1f321011292359ef163f78c8a1d4871b3b7freed@google.com virtual bool filterPath(SkPath* dst, const SkPath& src, 404bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com SkStrokeRec*, const SkRect*) const SK_OVERRIDE; 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 42ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect) 436bac947cd5bc460dd9166ada6310d678fd2e39f8reed@google.com 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 4539e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja SkDiscretePathEffect(SkScalar segLength, 4639e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja SkScalar deviation, 4739e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja uint32_t seedAssist); 48bd0be25074e53a6d1abc284562568c9745191984commit-bot@chromium.org explicit SkDiscretePathEffect(SkReadBuffer&); 49bd0be25074e53a6d1abc284562568c9745191984commit-bot@chromium.org virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 500a2bf90dccba3bde188e0386a7f0c60e6dde1ae9commit-bot@chromium.org 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar fSegLength, fPerterb; 53fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 5439e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja /* Caller-supplied 32 bit seed assist */ 5539e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja uint32_t fSeedAssist; 5639e58adb99111acbcc0b115e44812a3090bd6a2brs.prinja 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com typedef SkPathEffect INHERITED; 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 61