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 | |
| 11 | #include "SkPathEffect.h" |
| 12 | |
Mike Reed | 4123223 | 2018-03-07 17:02:47 -0500 | [diff] [blame] | 13 | class SkDashImpl : public SkPathEffect { |
Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 14 | public: |
| 15 | SkDashImpl(const SkScalar intervals[], int count, SkScalar phase); |
| 16 | |
Cary Clark | 4dc5a45 | 2018-05-21 11:56:57 -0400 | [diff] [blame] | 17 | Factory getFactory() const override { return CreateProc; } |
Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 18 | |
| 19 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 20 | bool exposedInAndroidJavaAPI() const override { return true; } |
| 21 | #endif |
| 22 | |
| 23 | protected: |
| 24 | ~SkDashImpl() override; |
| 25 | void flatten(SkWriteBuffer&) const override; |
Mike Reed | 6d10f8b | 2018-08-16 13:22:16 -0400 | [diff] [blame] | 26 | bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; |
| 27 | |
| 28 | bool onAsPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&, |
| 29 | const SkRect*) const override; |
| 30 | |
| 31 | DashType onAsADash(DashInfo* info) const override; |
Mike Reed | 76f7062 | 2017-05-23 23:00:14 -0400 | [diff] [blame] | 32 | |
| 33 | private: |
Cary Clark | 4dc5a45 | 2018-05-21 11:56:57 -0400 | [diff] [blame] | 34 | static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); |
| 35 | friend class SkFlattenable::PrivateInitializer; |
| 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 | |
| 46 | typedef SkPathEffect INHERITED; |
| 47 | }; |
| 48 | |
| 49 | #endif |