blob: 7f1de776c3c2a10f7a07df6dd52e6707952d0b2d [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
11#include "SkPathEffect.h"
12
Mike Reed41232232018-03-07 17:02:47 -050013class SkDashImpl : public SkPathEffect {
Mike Reed76f70622017-05-23 23:00:14 -040014public:
15 SkDashImpl(const SkScalar intervals[], int count, SkScalar phase);
16
17 bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
18
19 bool asPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&,
20 const SkRect*) const override;
21
22 DashType asADash(DashInfo* info) const override;
23
Cary Clark4dc5a452018-05-21 11:56:57 -040024 Factory getFactory() const override { return CreateProc; }
Mike Reed76f70622017-05-23 23:00:14 -040025
26#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
27 bool exposedInAndroidJavaAPI() const override { return true; }
28#endif
29
30protected:
31 ~SkDashImpl() override;
32 void flatten(SkWriteBuffer&) const override;
33
34private:
Cary Clark4dc5a452018-05-21 11:56:57 -040035 static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
36 friend class SkFlattenable::PrivateInitializer;
37
Mike Reed76f70622017-05-23 23:00:14 -040038 SkScalar* fIntervals;
39 int32_t fCount;
40 SkScalar fPhase;
41 // computed from phase
42
43 SkScalar fInitialDashLength;
44 int32_t fInitialDashIndex;
45 SkScalar fIntervalLength;
46
47 typedef SkPathEffect INHERITED;
48};
49
50#endif