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 "src/core/SkPathEffectBase.h" 13 14 namespace SkDashPath { 15 /** 16 * Calculates the initialDashLength, initialDashIndex, and intervalLength based on the 17 * inputed phase and intervals. If adjustedPhase is passed in, then the phase will be 18 * adjusted to be between 0 and intervalLength. The result will be stored in adjustedPhase. 19 * If adjustedPhase is nullptr then it is assumed phase is already between 0 and intervalLength 20 * 21 * Caller should have already used ValidDashPath to exclude invalid data. 22 */ 23 void CalcDashParameters(SkScalar phase, const SkScalar intervals[], int32_t count, 24 SkScalar* initialDashLength, int32_t* initialDashIndex, 25 SkScalar* intervalLength, SkScalar* adjustedPhase = nullptr); 26 27 bool FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*, 28 const SkPathEffectBase::DashInfo& info); 29 30 #ifdef SK_BUILD_FOR_FUZZER 31 const SkScalar kMaxDashCount = 10000; 32 #else 33 const SkScalar kMaxDashCount = 1000000; 34 #endif 35 36 /** See comments for InternalFilter */ 37 enum class StrokeRecApplication { 38 kDisallow, 39 kAllow, 40 }; 41 42 /** 43 * Caller should have already used ValidDashPath to exclude invalid data. Typically, this leaves 44 * the strokeRec unmodified. However, for some simple shapes (e.g. a line) it may directly 45 * evaluate the dash and stroke to produce a stroked output path with a fill strokeRec. Passing 46 * true for disallowStrokeRecApplication turns this behavior off. 47 */ 48 bool InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec, 49 const SkRect* cullRect, const SkScalar aIntervals[], 50 int32_t count, SkScalar initialDashLength, int32_t initialDashIndex, 51 SkScalar intervalLength, SkScalar startPhase, 52 StrokeRecApplication = StrokeRecApplication::kAllow); 53 54 bool ValidDashPath(SkScalar phase, const SkScalar intervals[], int32_t count); 55 } // namespace SkDashPath 56 57 #endif 58