SkPathEffect.h revision 687c57c7d5a17549f63e0b15208db18b220e2a91
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkPathEffect_DEFINED
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkPathEffect_DEFINED
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkFlattenable.h"
14fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com#include "SkPaint.h"
15629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com#include "SkPath.h"
16629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com#include "SkPoint.h"
17629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com#include "SkRect.h"
18629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com#include "SkTDArray.h"
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPath;
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
22fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.comclass SkStrokeRec {
23fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.compublic:
24fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    enum InitStyle {
25fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        kHairline_InitStyle,
26fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        kFill_InitStyle
27fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    };
28fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkStrokeRec(InitStyle style);
29fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
30fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkStrokeRec(const SkStrokeRec&);
31fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    explicit SkStrokeRec(const SkPaint&);
32fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
33fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    enum Style {
34fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        kHairline_Style,
35fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        kFill_Style,
36fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        kStroke_Style,
37fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        kStrokeAndFill_Style
38fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    };
39fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
40fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    Style getStyle() const;
41fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkScalar getWidth() const { return fWidth; }
42fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkScalar getMiter() const { return fMiterLimit; }
43fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkPaint::Cap getCap() const { return fCap; }
44fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkPaint::Join getJoin() const { return fJoin; }
45fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
46fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    bool isHairlineStyle() const {
47fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        return kHairline_Style == this->getStyle();
48fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    }
49fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
50fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    bool isFillStyle() const {
51fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        return kFill_Style == this->getStyle();
52fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    }
53fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
548b06f1a7ff6d5a59387a90433064550de20787eereed@google.com    void setFillStyle();
558b06f1a7ff6d5a59387a90433064550de20787eereed@google.com    void setHairlineStyle();
568b06f1a7ff6d5a59387a90433064550de20787eereed@google.com    /**
578b06f1a7ff6d5a59387a90433064550de20787eereed@google.com     *  Specify the strokewidth, and optionally if you want stroke + fill.
588b06f1a7ff6d5a59387a90433064550de20787eereed@google.com     *  Note, if width==0, then this request is taken to mean:
598b06f1a7ff6d5a59387a90433064550de20787eereed@google.com     *      strokeAndFill==true -> new style will be Fill
608b06f1a7ff6d5a59387a90433064550de20787eereed@google.com     *      strokeAndFill==false -> new style will be Hairline
618b06f1a7ff6d5a59387a90433064550de20787eereed@google.com     */
628b06f1a7ff6d5a59387a90433064550de20787eereed@google.com    void setStrokeStyle(SkScalar width, bool strokeAndFill = false);
63fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
64fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    void setStrokeParams(SkPaint::Cap cap, SkPaint::Join join, SkScalar miterLimit) {
65fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        fCap = cap;
66fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        fJoin = join;
67fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        fMiterLimit = miterLimit;
68fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    }
69fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
70fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    /**
71fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  Returns true if this specifes any thick stroking, i.e. applyToPath()
72fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  will return true.
73fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     */
74fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    bool needToApply() const {
75fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        Style style = this->getStyle();
76fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com        return (kStroke_Style == style) || (kStrokeAndFill_Style == style);
77fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    }
78fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
79fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    /**
80fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  Apply these stroke parameters to the src path, returning the result
81fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  in dst.
82fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *
83fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  If there was no change (i.e. style == hairline or fill) this returns
84fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  false and dst is unchanged. Otherwise returns true and the result is
85fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  stored in dst.
86fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *
87fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  src and dst may be the same path.
88fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     */
89fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    bool applyToPath(SkPath* dst, const SkPath& src) const;
90fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
91fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.comprivate:
92fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkScalar        fWidth;
93fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkScalar        fMiterLimit;
94fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkPaint::Cap    fCap;
95fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    SkPaint::Join   fJoin;
96fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    bool            fStrokeAndFill;
97fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com};
98fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com
998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkPathEffect
1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPathEffect is the base class for objects in the SkPaint that affect
1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    the geometry of a drawing primitive before it is transformed by the
1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    canvas' matrix and drawn.
1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Dashing is implemented as a subclass of SkPathEffect.
1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
1077ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkPathEffect : public SkFlattenable {
1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
1090456e0b7b85060e9b9597ce414c4c2b19aff4f58robertphillips@google.com    SK_DECLARE_INST_COUNT(SkPathEffect)
1100456e0b7b85060e9b9597ce414c4c2b19aff4f58robertphillips@google.com
1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPathEffect() {}
1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
113fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    /**
114fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  Given a src path (input) and a stroke-rec (input and output), apply
115fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  this effect to the src path, returning the new path in dst, and return
116fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  true. If this effect cannot be applied, return false and ignore dst
117fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  and stroke-rec.
118fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *
119fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  The stroke-rec specifies the initial request for stroking (if any).
120fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  The effect can treat this as input only, or it can choose to change
121fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  the rec as well. For example, the effect can decide to change the
122fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  stroke's width or join, or the effect can change the rec from stroke
123fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  to fill (or fill to stroke) in addition to returning a new (dst) path.
124fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *
125fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  If this method returns true, the caller will apply (as needed) the
126fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     *  resulting stroke-rec to dst and then draw.
127fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com     */
128fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) = 0;
1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
130e4f10a70807166484e5a6303a5cd0034e5e87abareed@google.com    /**
131e4f10a70807166484e5a6303a5cd0034e5e87abareed@google.com     *  Compute a conservative bounds for its effect, given the src bounds.
132e4f10a70807166484e5a6303a5cd0034e5e87abareed@google.com     *  The baseline implementation just assigns src to dst.
133e4f10a70807166484e5a6303a5cd0034e5e87abareed@google.com     */
134e4f10a70807166484e5a6303a5cd0034e5e87abareed@google.com    virtual void computeFastBounds(SkRect* dst, const SkRect& src);
135e4f10a70807166484e5a6303a5cd0034e5e87abareed@google.com
136629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com    /** \class PointData
137629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com
138629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        PointData aggregates all the information needed to draw the point
139687c57c7d5a17549f63e0b15208db18b220e2a91skia.committer@gmail.com        primitives returned by an 'asPoints' call.
140629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com    */
141629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com    class PointData {
142629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com    public:
143629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        PointData()
144629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com            : fFlags(0) {
145629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com            fSize.set(SK_Scalar1, SK_Scalar1);
146687c57c7d5a17549f63e0b15208db18b220e2a91skia.committer@gmail.com            // 'asPoints' needs to initialize/fill-in 'fClipRect' if it sets
147629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com            // the kUseClip flag
148629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        };
149629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        ~PointData() {};
150629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com
151629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        // TODO: consider using passed-in flags to limit the work asPoints does.
152629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        // For example, a kNoPath flag could indicate don't bother generating
153629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        // stamped solutions.
154629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com
155629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        // Currently none of these flags are supported.
156629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        enum PointFlags {
157629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com            kCircles_PointFlag            = 0x01,   // draw points as circles (instead of rects)
158629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com            kUsePath_PointFlag            = 0x02,   // draw points as stamps of the returned path
159629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com            kUseClip_PointFlag            = 0x04,   // apply 'fClipRect' before drawing the points
160629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        };
161629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com
162629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        uint32_t           fFlags;      // flags that impact the drawing of the points
163629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        // TODO: consider replacing the TDArray with either SkData or a ptr/len field
164629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        SkTDArray<SkPoint> fPoints;     // the center point of each generated point
165629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        SkVector           fSize;       // the size to draw the points
166629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        SkRect             fClipRect;   // clip required to draw the points (if kUseClip is set)
167629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com        SkPath             fPath;       // 'stamp' to be used at each point (if kUsePath is set)
168629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com    };
169629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com
170629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com    /**
171629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com     *  Does applying this path effect to 'src' yield a set of points? If so,
172629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com     *  optionally return the points in 'results'.
173629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com     */
174687c57c7d5a17549f63e0b15208db18b220e2a91skia.committer@gmail.com    virtual bool asPoints(PointData* results, const SkPath& src,
175629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com                          const SkStrokeRec&, const SkMatrix&) const;
176629ab540667422d3edcb97c51e9628b7051e1ba4robertphillips@google.com
177ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.comprotected:
178ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com    SkPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {}
179ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com
1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // illegal
1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPathEffect(const SkPathEffect&);
1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPathEffect& operator=(const SkPathEffect&);
184ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com
185ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com    typedef SkFlattenable INHERITED;
1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkPairPathEffect
1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Common baseclass for Compose and Sum. This subclass manages two pathEffects,
1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    including flattening them. It does nothing in filterPath, and is only useful
1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    for managing the lifetimes of its two arguments.
1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPairPathEffect : public SkPathEffect {
1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual ~SkPairPathEffect();
1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected:
2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPairPathEffect(SkFlattenableReadBuffer&);
20154924243c1b65b3ee6d8fa064b50a9b1bb2a19a5djsollen@google.com    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
20254924243c1b65b3ee6d8fa064b50a9b1bb2a19a5djsollen@google.com
2038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // these are visible to our subclasses
2048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPathEffect* fPE0, *fPE1;
205fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
2068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkPathEffect INHERITED;
2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkComposePathEffect
2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    This subclass of SkPathEffect composes its two arguments, to create
2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    a compound pathEffect.
2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkComposePathEffect : public SkPairPathEffect {
2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Construct a pathEffect whose effect is to apply first the inner pathEffect
2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        and the the outer pathEffect (e.g. outer(inner(path)))
2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        The reference counts for outer and inner are both incremented in the constructor,
2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        and decremented in the destructor.
2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        : INHERITED(outer, inner) {}
2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
225fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
227ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
22954924243c1b65b3ee6d8fa064b50a9b1bb2a19a5djsollen@google.comprotected:
2308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkComposePathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {}
2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
23254924243c1b65b3ee6d8fa064b50a9b1bb2a19a5djsollen@google.comprivate:
2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // illegal
2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkComposePathEffect(const SkComposePathEffect&);
2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkComposePathEffect& operator=(const SkComposePathEffect&);
236fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkPairPathEffect INHERITED;
2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkSumPathEffect
2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    This subclass of SkPathEffect applies two pathEffects, one after the other.
2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Its filterPath() returns true if either of the effects succeeded.
2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkSumPathEffect : public SkPairPathEffect {
2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Construct a pathEffect whose effect is to apply two effects, in sequence.
2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (e.g. first(path) + second(path))
2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        The reference counts for first and second are both incremented in the constructor,
2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        and decremented in the destructor.
2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        : INHERITED(first, second) {}
2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
255fd4be26c4202ae91f0f7cf2c03e44b5169d885ebreed@google.com    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
257ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
25954924243c1b65b3ee6d8fa064b50a9b1bb2a19a5djsollen@google.comprotected:
2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkSumPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {}
2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
26254924243c1b65b3ee6d8fa064b50a9b1bb2a19a5djsollen@google.comprivate:
2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // illegal
2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkSumPathEffect(const SkSumPathEffect&);
2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkSumPathEffect& operator=(const SkSumPathEffect&);
2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkPairPathEffect INHERITED;
2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
2718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
272