aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkDashPathPriv.h
blob: 752b59dbea9b4426e4d0891ceb9a116558720d46 (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
51
52
/*
 * Copyright 2014 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkDashPathPriv_DEFINED
#define SkDashPathPriv_DEFINED

#include "SkPathEffect.h"

namespace SkDashPath {
    /**
     * Calculates the initialDashLength, initialDashIndex, and intervalLength based on the
     * inputed phase and intervals. If adjustedPhase is passed in, then the phase will be
     * adjusted to be between 0 and intervalLength. The result will be stored in adjustedPhase.
     * If adjustedPhase is nullptr then it is assumed phase is already between 0 and intervalLength
     *
     * Caller should have already used ValidDashPath to exclude invalid data.
     */
    void CalcDashParameters(SkScalar phase, const SkScalar intervals[], int32_t count,
                            SkScalar* initialDashLength, int32_t* initialDashIndex,
                            SkScalar* intervalLength, SkScalar* adjustedPhase = nullptr);

    bool FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
                        const SkPathEffect::DashInfo& info);

    const SkScalar kMaxDashCount = 1000000;

    /** See comments for InternalFilter */
    enum class StrokeRecApplication {
        kDisallow,
        kAllow,
    };

    /**
     * Caller should have already used ValidDashPath to exclude invalid data. Typically, this leaves
     * the strokeRec unmodified. However, for some simple shapes (e.g. a line) it may directly
     * evaluate the dash and stroke to produce a stroked output path with a fill strokeRec. Passing
     * true for disallowStrokeRecApplication turns this behavior off.
     */
    bool InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
                        const SkRect* cullRect, const SkScalar aIntervals[],
                        int32_t count, SkScalar initialDashLength, int32_t initialDashIndex,
                        SkScalar intervalLength,
                        StrokeRecApplication = StrokeRecApplication::kAllow);

    bool ValidDashPath(SkScalar phase, const SkScalar intervals[], int32_t count);
}

#endif