Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 SkDashImpl_DEFINED |
| 9 | #define SkDashImpl_DEFINED |
| 10 | |
Mike Reed | ec9d0e8 | 2021-05-21 17:42:14 -0400 | [diff] [blame] | 11 | #include "src/core/SkPathEffectBase.h" |
Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 12 | |
Mike Reed | ec9d0e8 | 2021-05-21 17:42:14 -0400 | [diff] [blame] | 13 | class SkDashImpl : public SkPathEffectBase { |
Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 14 | public: |
| 15 | SkDashImpl(const SkScalar intervals[], int count, SkScalar phase); |
| 16 | |
Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 17 | protected: |
| 18 | ~SkDashImpl() override; |
| 19 | void flatten(SkWriteBuffer&) const override; |
Tyler Denniston | f8b7c1a | 2021-07-13 13:22:19 -0400 | [diff] [blame] | 20 | bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*, |
| 21 | const SkMatrix&) const override; |
Mike Reed | 6d10f8b | 2018-08-16 13:22:16 -0400 | [diff] [blame] | 22 | |
| 23 | bool onAsPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&, |
| 24 | const SkRect*) const override; |
| 25 | |
| 26 | DashType onAsADash(DashInfo* info) const override; |
Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 27 | |
| 28 | private: |
Mike Klein | 4fee323 | 2018-10-18 17:27:16 -0400 | [diff] [blame] | 29 | SK_FLATTENABLE_HOOKS(SkDashImpl) |
Cary Clark | 4dc5a45 | 2018-05-21 11:56:57 -0400 | [diff] [blame] | 30 | |
Michael Ludwig | 4e1c1a7 | 2021-05-11 11:39:36 -0400 | [diff] [blame] | 31 | bool computeFastBounds(SkRect* bounds) const override { |
| 32 | // Dashing a path returns a subset of the input path so just return true and leave |
| 33 | // bounds unmodified |
| 34 | return true; |
| 35 | } |
| 36 | |
Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 37 | SkScalar* fIntervals; |
| 38 | int32_t fCount; |
| 39 | SkScalar fPhase; |
| 40 | // computed from phase |
| 41 | |
| 42 | SkScalar fInitialDashLength; |
| 43 | int32_t fInitialDashIndex; |
| 44 | SkScalar fIntervalLength; |
| 45 | |
Mike Reed | ec9d0e8 | 2021-05-21 17:42:14 -0400 | [diff] [blame] | 46 | using INHERITED = SkPathEffectBase; |
Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | #endif |