aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/SkDashImpl.h
blob: 7f1de776c3c2a10f7a07df6dd52e6707952d0b2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkDashImpl_DEFINED
#define SkDashImpl_DEFINED

#include "SkPathEffect.h"

class SkDashImpl : public SkPathEffect {
public:
    SkDashImpl(const SkScalar intervals[], int count, SkScalar phase);

    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;

    bool asPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&,
                  const SkRect*) const override;

    DashType asADash(DashInfo* info) const override;

    Factory getFactory() const override { return CreateProc; }

#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
    bool exposedInAndroidJavaAPI() const override { return true; }
#endif

protected:
    ~SkDashImpl() override;
    void flatten(SkWriteBuffer&) const override;

private:
    static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
    friend class SkFlattenable::PrivateInitializer;

    SkScalar*   fIntervals;
    int32_t     fCount;
    SkScalar    fPhase;
    // computed from phase

    SkScalar    fInitialDashLength;
    int32_t     fInitialDashIndex;
    SkScalar    fIntervalLength;

    typedef SkPathEffect INHERITED;
};

#endif