| 1 |
/* |
| 2 |
* Copyright 2006 The Android Open Source Project |
| 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 SkPathEffect_DEFINED |
| 9 |
#define SkPathEffect_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkFlattenable.h" |
| 12 |
#include "include/core/SkRefCnt.h" |
| 13 |
#include "include/core/SkTypes.h" |
| 14 |
|
| 15 |
// TODO(kjlubick) update clients and remove this unnecessary #include |
| 16 |
#include "include/core/SkPath.h" // IWYU pragma: keep |
| 17 |
|
| 18 |
#include <cstddef> |
| 19 |
|
| 20 |
class SkMatrix; |
| 21 |
class SkPathBuilder; |
| 22 |
class SkStrokeRec; |
| 23 |
struct SkDeserialProcs; |
| 24 |
struct SkRect; |
| 25 |
|
| 26 |
/** \class SkPathEffect |
| 27 |
|
| 28 |
SkPathEffect is the base class for objects in the SkPaint that affect |
| 29 |
the geometry of a drawing primitive before it is transformed by the |
| 30 |
canvas' matrix and drawn. |
| 31 |
|
| 32 |
Dashing is implemented as a subclass of SkPathEffect. |
| 33 |
*/ |
| 34 |
class SK_API SkPathEffect : public SkFlattenable { |
| 35 |
public: |
| 36 |
/** |
| 37 |
* Returns a patheffect that apples each effect (first and second) to the original path, |
| 38 |
* and returns a path with the sum of these. |
| 39 |
* |
| 40 |
* result = first(path) + second(path) |
| 41 |
* |
| 42 |
*/ |
| 43 |
static sk_sp<SkPathEffect> MakeSum(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second); |
| 44 |
|
| 45 |
/** |
| 46 |
* Returns a patheffect that applies the inner effect to the path, and then applies the |
| 47 |
* outer effect to the result of the inner's. |
| 48 |
* |
| 49 |
* result = outer(inner(path)) |
| 50 |
*/ |
| 51 |
static sk_sp<SkPathEffect> MakeCompose(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner); |
| 52 |
|
| 53 |
static SkFlattenable::Type GetFlattenableType() { |
| 54 |
return kSkPathEffect_Type; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Given a src path (input) and a stroke-rec (input and output), apply |
| 59 |
* this effect to the src path, returning the new path in dst, and return |
| 60 |
* true. If this effect cannot be applied, return false and ignore dst |
| 61 |
* and stroke-rec. |
| 62 |
* |
| 63 |
* The stroke-rec specifies the initial request for stroking (if any). |
| 64 |
* The effect can treat this as input only, or it can choose to change |
| 65 |
* the rec as well. For example, the effect can decide to change the |
| 66 |
* stroke's width or join, or the effect can change the rec from stroke |
| 67 |
* to fill (or fill to stroke) in addition to returning a new (dst) path. |
| 68 |
* |
| 69 |
* If this method returns true, the caller will apply (as needed) the |
| 70 |
* resulting stroke-rec to dst and then draw. |
| 71 |
*/ |
| 72 |
bool filterPath(SkPathBuilder* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR, |
| 73 |
const SkMatrix& ctm) const; |
| 74 |
bool filterPath(SkPathBuilder* dst, const SkPath& src, SkStrokeRec*) const; |
| 75 |
|
| 76 |
/** True if this path effect requires a valid CTM */ |
| 77 |
bool needsCTM() const; |
| 78 |
|
| 79 |
static sk_sp<SkPathEffect> Deserialize(const void* data, size_t size, |
| 80 |
const SkDeserialProcs* procs = nullptr); |
| 81 |
private: |
| 82 |
SkPathEffect() = default; |
| 83 |
friend class SkPathEffectBase; |
| 84 |
|
| 85 |
using INHERITED = SkFlattenable; |
| 86 |
}; |
| 87 |
|
| 88 |
#endif |