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 Sk1DPathEffect_DEFINED 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define Sk1DPathEffect_DEFINED 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPathEffect.h" 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPath.h" 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPathMeasure; 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 166806fe87e0b39e283291c1a1c7d1d864230aa2aatfarina@chromium.org// This class is not exported to java. 176806fe87e0b39e283291c1a1c7d1d864230aa2aatfarina@chromium.orgclass SK_API Sk1DPathEffect : public SkPathEffect { 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 19548a1f321011292359ef163f78c8a1d4871b3b7freed@google.com virtual bool filterPath(SkPath* dst, const SkPath& src, 204bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com SkStrokeRec*, const SkRect*) const SK_OVERRIDE; 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Called at the start of each contour, returns the initial offset 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com into that contour. 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 26548a1f321011292359ef163f78c8a1d4871b3b7freed@google.com virtual SkScalar begin(SkScalar contourLength) const = 0; 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Called with the current distance along the path, with the current matrix 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com for the point/tangent at the specified distance. 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Return the distance to travel for the next call. If return <= 0, then that 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com contour is done. 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 32548a1f321011292359ef163f78c8a1d4871b3b7freed@google.com virtual SkScalar next(SkPath* dst, SkScalar dist, SkPathMeasure&) const = 0; 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com typedef SkPathEffect INHERITED; 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 386806fe87e0b39e283291c1a1c7d1d864230aa2aatfarina@chromium.orgclass SK_API SkPath1DPathEffect : public Sk1DPathEffect { 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum Style { 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kTranslate_Style, // translate the shape to each position 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kRotate_Style, // rotate the shape about its center 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kMorph_Style, // transform each point, and turn lines into curves 44fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kStyleCount 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 47fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Dash by replicating the specified path. 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path to replicate (dash) 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param advance The space between instances of path 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param phase distance (mod advance) along path for its initial position 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param style how to transform path at each point (based on the current 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com position and tangent) 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 550a2bf90dccba3bde188e0386a7f0c60e6dde1ae9commit-bot@chromium.org static SkPath1DPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, 560a2bf90dccba3bde188e0386a7f0c60e6dde1ae9commit-bot@chromium.org Style style) { 570a2bf90dccba3bde188e0386a7f0c60e6dde1ae9commit-bot@chromium.org return SkNEW_ARGS(SkPath1DPathEffect, (path, advance, phase, style)); 580a2bf90dccba3bde188e0386a7f0c60e6dde1ae9commit-bot@chromium.org } 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 60548a1f321011292359ef163f78c8a1d4871b3b7freed@google.com virtual bool filterPath(SkPath*, const SkPath&, 614bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com SkStrokeRec*, const SkRect*) const SK_OVERRIDE; 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 63ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect) 64e28b917669fc4677b2f1c0a08c4711b651cbf1a1reed@google.com 658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 66bd0be25074e53a6d1abc284562568c9745191984commit-bot@chromium.org SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style); 67bd0be25074e53a6d1abc284562568c9745191984commit-bot@chromium.org explicit SkPath1DPathEffect(SkReadBuffer& buffer); 688b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // overrides from Sk1DPathEffect 71548a1f321011292359ef163f78c8a1d4871b3b7freed@google.com virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE; 72548a1f321011292359ef163f78c8a1d4871b3b7freed@google.com virtual SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const SK_OVERRIDE; 73fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPath fPath; // copied from constructor 768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar fAdvance; // copied from constructor 778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar fInitialOffset; // computed from phase 788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Style fStyle; // copied from constructor 798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com typedef Sk1DPathEffect INHERITED; 818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 84