reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef SkDashPathEffect_DEFINED |
| 18 | #define SkDashPathEffect_DEFINED |
| 19 | |
| 20 | #include "SkPathEffect.h" |
| 21 | |
| 22 | /** \class SkDashPathEffect |
| 23 | |
| 24 | SkDashPathEffect is a subclass of SkPathEffect that implements dashing |
| 25 | */ |
| 26 | class SkDashPathEffect : public SkPathEffect { |
| 27 | public: |
| 28 | /** The intervals array must contain an even number of entries (>=2), with the even |
| 29 | indices specifying the "on" intervals, and the odd indices specifying the "off" |
| 30 | intervals. phase is an offset into the intervals array (mod the sum of all of the |
| 31 | intervals). |
| 32 | Note: only affects framed paths |
| 33 | */ |
| 34 | SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit = false); |
| 35 | virtual ~SkDashPathEffect(); |
| 36 | |
| 37 | // overrides for SkPathEffect |
| 38 | // This method is not exported to java. |
| 39 | virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width); |
| 40 | |
| 41 | // overrides for SkFlattenable |
| 42 | // This method is not exported to java. |
| 43 | virtual Factory getFactory(); |
| 44 | // This method is not exported to java. |
| 45 | virtual void flatten(SkFlattenableWriteBuffer&); |
| 46 | |
| 47 | protected: |
| 48 | SkDashPathEffect(SkFlattenableReadBuffer&); |
| 49 | |
| 50 | private: |
| 51 | SkScalar* fIntervals; |
| 52 | int32_t fCount; |
| 53 | // computed from phase |
| 54 | SkScalar fInitialDashLength; |
| 55 | int32_t fInitialDashIndex; |
| 56 | SkScalar fIntervalLength; |
| 57 | bool fScaleToFit; |
| 58 | |
| 59 | static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); |
| 60 | |
| 61 | typedef SkPathEffect INHERITED; |
| 62 | }; |
| 63 | |
| 64 | #endif |
| 65 | |