Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Side by Side Diff: src/utils/SkDashPathPriv.h

Issue 2165013002: limit the number of points in SkDashPathEffect::asPoints (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fix SpecialLineRec point count overflow Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkDashPathPriv_DEFINED 8 #ifndef SkDashPathPriv_DEFINED
9 #define SkDashPathPriv_DEFINED 9 #define SkDashPathPriv_DEFINED
10 10
11 #include "SkPathEffect.h" 11 #include "SkPathEffect.h"
12 12
13 namespace SkDashPath { 13 namespace SkDashPath {
14 /** 14 /**
15 * Calculates the initialDashLength, initialDashIndex, and intervalLength ba sed on the 15 * Calculates the initialDashLength, initialDashIndex, and intervalLength ba sed on the
16 * inputed phase and intervals. If adjustedPhase is passed in, then the phas e will be 16 * inputed phase and intervals. If adjustedPhase is passed in, then the phas e will be
17 * adjusted to be between 0 and intervalLength. The result will be stored in adjustedPhase. 17 * adjusted to be between 0 and intervalLength. The result will be stored in adjustedPhase.
18 * If adjustedPhase is nullptr then it is assumed phase is already between 0 and intervalLength 18 * If adjustedPhase is nullptr then it is assumed phase is already between 0 and intervalLength
19 * 19 *
20 * Caller should have already used ValidDashPath to exclude invalid data. 20 * Caller should have already used ValidDashPath to exclude invalid data.
21 */ 21 */
22 void CalcDashParameters(SkScalar phase, const SkScalar intervals[], int32_t count, 22 void CalcDashParameters(SkScalar phase, const SkScalar intervals[], int32_t count,
23 SkScalar* initialDashLength, int32_t* initialDashInd ex, 23 SkScalar* initialDashLength, int32_t* initialDashInd ex,
24 SkScalar* intervalLength, SkScalar* adjustedPhase = nullptr); 24 SkScalar* intervalLength, SkScalar* adjustedPhase = nullptr);
25 25
26 bool FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRe ct*, 26 bool FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRe ct*,
27 const SkPathEffect::DashInfo& info); 27 const SkPathEffect::DashInfo& info);
28 28
29 const SkScalar kMaxDashCount = 1000000;
30
29 /** See comments for InternalFilter */ 31 /** See comments for InternalFilter */
30 enum class StrokeRecApplication { 32 enum class StrokeRecApplication {
31 kDisallow, 33 kDisallow,
32 kAllow, 34 kAllow,
33 }; 35 };
34 36
35 /** 37 /**
36 * Caller should have already used ValidDashPath to exclude invalid data. Ty pically, this leaves 38 * Caller should have already used ValidDashPath to exclude invalid data. Ty pically, this leaves
37 * the strokeRec unmodified. However, for some simple shapes (e.g. a line) i t may directly 39 * the strokeRec unmodified. However, for some simple shapes (e.g. a line) i t may directly
38 * evaluate the dash and stroke to produce a stroked output path with a fill strokeRec. Passing 40 * evaluate the dash and stroke to produce a stroked output path with a fill strokeRec. Passing
39 * true for disallowStrokeRecApplication turns this behavior off. 41 * true for disallowStrokeRecApplication turns this behavior off.
40 */ 42 */
41 bool InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec, 43 bool InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
42 const SkRect* cullRect, const SkScalar aIntervals[], 44 const SkRect* cullRect, const SkScalar aIntervals[],
43 int32_t count, SkScalar initialDashLength, int32_t initi alDashIndex, 45 int32_t count, SkScalar initialDashLength, int32_t initi alDashIndex,
44 SkScalar intervalLength, 46 SkScalar intervalLength,
45 StrokeRecApplication = StrokeRecApplication::kAllow); 47 StrokeRecApplication = StrokeRecApplication::kAllow);
46 48
47 bool ValidDashPath(SkScalar phase, const SkScalar intervals[], int32_t count ); 49 bool ValidDashPath(SkScalar phase, const SkScalar intervals[], int32_t count );
48 } 50 }
49 51
50 #endif 52 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698