blob: 8439ca0f19f13801302c55197bb4886496c10346 [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;
Tyler Dennistonf8b7c1a2021-07-13 13:22:19 -040020 bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
21 const SkMatrix&) const override;
Mike Reed6d10f8b2018-08-16 13:22:16 -040022
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 Reed76f70622017-05-23 23:00:14 -040027
28private:
Mike Klein4fee3232018-10-18 17:27:16 -040029 SK_FLATTENABLE_HOOKS(SkDashImpl)
Cary Clark4dc5a452018-05-21 11:56:57 -040030
Michael Ludwig4e1c1a72021-05-11 11:39:36 -040031 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 Reed76f70622017-05-23 23:00:14 -040037 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 Reedec9d0e82021-05-21 17:42:14 -040046 using INHERITED = SkPathEffectBase;
Mike Reed76f70622017-05-23 23:00:14 -040047};
48
49#endif