Debian Codegraph @

src/effects/SkDashImpl.h

raw
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 "include/core/SkSpan.h"
12 #include "include/private/base/SkTemplates.h"
13 #include "src/core/SkPathEffectBase.h"
14
15 #include <optional>
16
17 class SkDashImpl : public SkPathEffectBase {
18 public:
19 SkDashImpl(SkSpan<const SkScalar> intervals, SkScalar phase);
20
21 protected:
22 void flatten(SkWriteBuffer&) const override;
23 bool onFilterPath(SkPathBuilder* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
24 const SkMatrix&) const override;
25
26 bool onAsPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&,
27 const SkRect*) const override;
28
29 std::optional<DashInfo> asADash() const override;
30
31 private:
32 SK_FLATTENABLE_HOOKS(SkDashImpl)
33
34 bool computeFastBounds(SkRect* bounds) const override {
35 // Dashing a path returns a subset of the input path so just return true and leave
36 // bounds unmodified
37 return true;
38 }
39
40 skia_private::AutoTArray<SkScalar> fIntervals;
41 SkScalar fPhase;
42
43 // computed from phase
44 SkScalar fInitialDashLength;
45 SkScalar fIntervalLength;
46 size_t fInitialDashIndex;
47
48 using INHERITED = SkPathEffectBase;
49 };
50
51 #endif