blob: 752b59dbea9b4426e4d0891ceb9a116558720d46 [file] [log] [blame]
egdaniela22ea182014-06-11 06:51:51 -07001/*
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 "SkPathEffect.h"
12
13namespace SkDashPath {
bsalomon398e3f42016-06-13 10:22:48 -070014 /**
egdaniela22ea182014-06-11 06:51:51 -070015 * Calculates the initialDashLength, initialDashIndex, and intervalLength based on the
16 * inputed phase and intervals. If adjustedPhase is passed in, then the phase will be
17 * adjusted to be between 0 and intervalLength. The result will be stored in adjustedPhase.
halcanary96fcdcc2015-08-27 07:41:13 -070018 * If adjustedPhase is nullptr then it is assumed phase is already between 0 and intervalLength
caryclarkeb75c7d2016-03-18 06:04:26 -070019 *
20 * Caller should have already used ValidDashPath to exclude invalid data.
egdaniela22ea182014-06-11 06:51:51 -070021 */
22 void CalcDashParameters(SkScalar phase, const SkScalar intervals[], int32_t count,
23 SkScalar* initialDashLength, int32_t* initialDashIndex,
halcanary96fcdcc2015-08-27 07:41:13 -070024 SkScalar* intervalLength, SkScalar* adjustedPhase = nullptr);
egdaniela22ea182014-06-11 06:51:51 -070025
26 bool FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
egdaniela22ea182014-06-11 06:51:51 -070027 const SkPathEffect::DashInfo& info);
caryclarkeb75c7d2016-03-18 06:04:26 -070028
lsalzmanf41ae2f2016-07-21 09:37:59 -070029 const SkScalar kMaxDashCount = 1000000;
30
bsalomon398e3f42016-06-13 10:22:48 -070031 /** See comments for InternalFilter */
32 enum class StrokeRecApplication {
33 kDisallow,
34 kAllow,
35 };
36
37 /**
38 * Caller should have already used ValidDashPath to exclude invalid data. Typically, this leaves
39 * the strokeRec unmodified. However, for some simple shapes (e.g. a line) it may directly
40 * evaluate the dash and stroke to produce a stroked output path with a fill strokeRec. Passing
41 * true for disallowStrokeRecApplication turns this behavior off.
caryclarkeb75c7d2016-03-18 06:04:26 -070042 */
43 bool InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
44 const SkRect* cullRect, const SkScalar aIntervals[],
45 int32_t count, SkScalar initialDashLength, int32_t initialDashIndex,
bsalomon398e3f42016-06-13 10:22:48 -070046 SkScalar intervalLength,
47 StrokeRecApplication = StrokeRecApplication::kAllow);
caryclarkeb75c7d2016-03-18 06:04:26 -070048
49 bool ValidDashPath(SkScalar phase, const SkScalar intervals[], int32_t count);
egdaniela22ea182014-06-11 06:51:51 -070050}
51
52#endif