Debian Codegraph @

src/utils/SkDashPathPriv.h

raw
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkDashPathPriv_DEFINED
9 #define SkDashPathPriv_DEFINED
10
11 #include "include/core/SkPathEffect.h"
12 #include "include/core/SkSpan.h"
13 #include "src/core/SkPathEffectBase.h"
14
15 namespace SkDashPath {
16 /**
17 * Calculates the initialDashLength, initialDashIndex, and intervalLength based on the
18 * inputed phase and intervals. If adjustedPhase is passed in, then the phase will be
19 * adjusted to be between 0 and intervalLength. The result will be stored in adjustedPhase.
20 * If adjustedPhase is nullptr then it is assumed phase is already between 0 and intervalLength
21 *
22 * Caller should have already used ValidDashPath to exclude invalid data.
23 */
24 void CalcDashParameters(SkScalar phase, SkSpan<const SkScalar> intervals,
25 SkScalar* initialDashLength, size_t* initialDashIndex,
26 SkScalar* intervalLength, SkScalar* adjustedPhase = nullptr);
27
28 bool FilterDashPath(SkPathBuilder* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
29 const SkPathEffectBase::DashInfo& info);
30
31 #ifdef SK_BUILD_FOR_FUZZER
32 const SkScalar kMaxDashCount = 10000;
33 #else
34 const SkScalar kMaxDashCount = 1000000;
35 #endif
36
37 /** See comments for InternalFilter */
38 enum class StrokeRecApplication {
39 kDisallow,
40 kAllow,
41 };
42
43 /**
44 * Caller should have already used ValidDashPath to exclude invalid data. Typically, this leaves
45 * the strokeRec unmodified. However, for some simple shapes (e.g. a line) it may directly
46 * evaluate the dash and stroke to produce a stroked output path with a fill strokeRec. Passing
47 * true for disallowStrokeRecApplication turns this behavior off.
48 */
49 bool InternalFilter(SkPathBuilder* dst, const SkPath& src, SkStrokeRec* rec,
50 const SkRect* cullRect, SkSpan<const SkScalar> aIntervals,
51 SkScalar initialDashLength, int32_t initialDashIndex,
52 SkScalar intervalLength, SkScalar startPhase,
53 StrokeRecApplication = StrokeRecApplication::kAllow);
54
55 bool ValidDashPath(SkScalar phase, SkSpan<const SkScalar> intervals);
56
57 } // namespace SkDashPath
58
59 #endif