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,
2036352bf5e38f45a70ee4f4fc132a38048d38206dmtklein                            SkStrokeRec*, const SkRect*) const 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
3464de1e179012302d5f3b805d0736a583ad91c6a2tomhudson#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
3536352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    bool exposedInAndroidJavaAPI() const override { return true; }
3664de1e179012302d5f3b805d0736a583ad91c6a2tomhudson#endif
3764de1e179012302d5f3b805d0736a583ad91c6a2tomhudson
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkPathEffect INHERITED;
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
426806fe87e0b39e283291c1a1c7d1d864230aa2aatfarina@chromium.orgclass SK_API SkPath1DPathEffect : public Sk1DPathEffect {
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Style {
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kTranslate_Style,   // translate the shape to each position
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kRotate_Style,      // rotate the shape about its center
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kMorph_Style,       // transform each point, and turn lines into curves
4823e7af0e8ab8377b28e1399b4950def672284724ethannicholas
49ca726abe1e4a2522b24e5143c5faf0e594a4802areed        kLastEnum_Style = kMorph_Style,
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
51fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Dash by replicating the specified path.
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param path The path to replicate (dash)
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param advance The space between instances of path
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param phase distance (mod advance) along path for its initial position
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param style how to transform path at each point (based on the current
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     position and tangent)
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
59ca726abe1e4a2522b24e5143c5faf0e594a4802areed    static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style);
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
61548a1f321011292359ef163f78c8a1d4871b3b7freed@google.com    virtual bool filterPath(SkPath*, const SkPath&,
6236352bf5e38f45a70ee4f4fc132a38048d38206dmtklein                            SkStrokeRec*, const SkRect*) const override;
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6442dbfa8651861f2f686879c996aab9f9f82277ddrobertphillips    SK_TO_STRING_OVERRIDE()
65ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect)
66e28b917669fc4677b2f1c0a08c4711b651cbf1a1reed@google.com
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected:
68bd0be25074e53a6d1abc284562568c9745191984commit-bot@chromium.org    SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
6936352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    void flatten(SkWriteBuffer&) const override;
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // overrides from Sk1DPathEffect
7236352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    SkScalar begin(SkScalar contourLength) const override;
7336352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const override;
74fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPath      fPath;          // copied from constructor
778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar    fAdvance;       // copied from constructor
788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar    fInitialOffset; // computed from phase
798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Style       fStyle;         // copied from constructor
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef Sk1DPathEffect INHERITED;
828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
85