blob: fbb343c9f660fda10c60240dac6114d1538641ce [file] [log] [blame]
Mike Reed76f70622017-05-23 23:00:14 -04001/*
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 Reedec9d0e82021-05-21 17:42:14 -040011#include "src/core/SkPathEffectBase.h"
Mike Reed76f70622017-05-23 23:00:14 -040012
Mike Reedec9d0e82021-05-21 17:42:14 -040013class SkDashImpl : public SkPathEffectBase {
Mike Reed76f70622017-05-23 23:00:14 -040014public:
15 SkDashImpl(const SkScalar intervals[], int count, SkScalar phase);
16
Mike Reed76f70622017-05-23 23:00:14 -040017protected:
18 ~SkDashImpl() override;
19 void flatten(SkWriteBuffer&) const override;
Mike Reed6d10f8b2018-08-16 13:22:16 -040020 bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
21
22 bool onAsPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&,
23 const SkRect*) const override;
24
25 DashType onAsADash(DashInfo* info) const override;
Mike Reed76f70622017-05-23 23:00:14 -040026
27private:
Mike Klein4fee3232018-10-18 17:27:16 -040028 SK_FLATTENABLE_HOOKS(SkDashImpl)
Cary Clark4dc5a452018-05-21 11:56:57 -040029
Michael Ludwig4e1c1a72021-05-11 11:39:36 -040030 bool computeFastBounds(SkRect* bounds) const override {
31 // Dashing a path returns a subset of the input path so just return true and leave
32 // bounds unmodified
33 return true;
34 }
35
Mike Reed76f70622017-05-23 23:00:14 -040036 SkScalar* fIntervals;
37 int32_t fCount;
38 SkScalar fPhase;
39 // computed from phase
40
41 SkScalar fInitialDashLength;
42 int32_t fInitialDashIndex;
43 SkScalar fIntervalLength;
44
Mike Reedec9d0e82021-05-21 17:42:14 -040045 using INHERITED = SkPathEffectBase;
Mike Reed76f70622017-05-23 23:00:14 -040046};
47
48#endif