• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 SkOpPE_DEFINED
9 #define SkOpPE_DEFINED
10 
11 #include "include/pathops/SkPathOps.h"
12 #include "src/core/SkPathEffectBase.h"
13 
14 class SkOpPE : public SkPathEffectBase {
15 public:
16     SkOpPE(sk_sp<SkPathEffect> one, sk_sp<SkPathEffect> two, SkPathOp op);
17 
18 
19 protected:
20     void flatten(SkWriteBuffer&) const override;
21     bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
22                       const SkMatrix&) const override;
23 
24 private:
25     SK_FLATTENABLE_HOOKS(SkOpPE)
26 
27     bool computeFastBounds(SkRect* bounds) const override;
28 
29     sk_sp<SkPathEffect> fOne;
30     sk_sp<SkPathEffect> fTwo;
31     SkPathOp            fOp;
32 
33     using INHERITED = SkPathEffectBase;
34 };
35 
36 class SkMatrixPE : public SkPathEffectBase {
37 public:
38     SkMatrixPE(const SkMatrix&);
39 
40 protected:
41     void flatten(SkWriteBuffer&) const override;
42     bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
43                       const SkMatrix&) const override;
44 
45 private:
SK_FLATTENABLE_HOOKS(SkMatrixPE)46     SK_FLATTENABLE_HOOKS(SkMatrixPE)
47 
48     bool computeFastBounds(SkRect* bounds) const override {
49         if (bounds) {
50             fMatrix.mapRect(bounds);
51         }
52         return true;
53     }
54 
55     SkMatrix    fMatrix;
56 
57     using INHERITED = SkPathEffectBase;
58 };
59 
60 class SkStrokePE : public SkPathEffectBase {
61 public:
62     SkStrokePE(SkScalar width, SkPaint::Join, SkPaint::Cap, SkScalar miter);
63 
64 protected:
65     void flatten(SkWriteBuffer&) const override;
66     bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
67                       const SkMatrix&) const override;
68 
69 private:
70     SK_FLATTENABLE_HOOKS(SkStrokePE)
71 
72     bool computeFastBounds(SkRect* bounds) const override;
73 
74     SkScalar        fWidth,
75                     fMiter;
76     SkPaint::Join   fJoin;
77     SkPaint::Cap    fCap;
78 
79     using INHERITED = SkPathEffectBase;
80 };
81 
82 class SkStrokeAndFillPE : public SkPathEffectBase {
83 public:
SkStrokeAndFillPE()84     SkStrokeAndFillPE() {}
85 
86 protected:
87     void flatten(SkWriteBuffer&) const override;
88     bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
89                       const SkMatrix&) const override;
90 
91 private:
SK_FLATTENABLE_HOOKS(SkStrokeAndFillPE)92     SK_FLATTENABLE_HOOKS(SkStrokeAndFillPE)
93 
94     bool computeFastBounds(SkRect* bounds) const override {
95         // The effect's bounds depend on the StrokeRect that is not yet available
96         return false;
97     }
98 
99     using INHERITED = SkPathEffectBase;
100 };
101 
102 #endif
103