Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
SkTrimPE Class Reference

#include <SkTrimPE.h>

Inheritance diagram for SkTrimPE:
SkPathEffectBase SkPathEffect SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkTrimPE (SkScalar startT, SkScalar stopT, SkTrimPathEffect::Mode)
 
- Public Member Functions inherited from SkPathEffectBase
 SkPathEffectBase ()
 
bool asPoints (PointData *results, const SkPath &src, const SkStrokeRec &, const SkMatrix &, const SkRect *cullR) const
 
SkFlattenable::Type getFlattenableType () const override
 
virtual bool onNeedsCTM () const
 
virtual bool onAsPoints (PointData *, const SkPath &, const SkStrokeRec &, const SkMatrix &, const SkRect *) const
 
virtual DashType onAsADash (DashInfo *) const
 
- Public Member Functions inherited from SkPathEffect
DashType asADash (DashInfo *info) const
 
bool filterPath (SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *cullR) const
 
bool filterPath (SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *cullR, const SkMatrix &ctm) const
 
bool needsCTM () const
 
- Public Member Functions inherited from SkFlattenable
 SkFlattenable ()
 
virtual Factory getFactory () const =0
 
virtual const char * getTypeName () const =0
 
sk_sp< SkDataserialize (const SkSerialProcs *=nullptr) const
 
size_t serialize (void *memory, size_t memory_size, const SkSerialProcs *=nullptr) const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

void flatten (SkWriteBuffer &) const override
 
bool onFilterPath (SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *, const SkMatrix &) const override
 

Private Member Functions

bool computeFastBounds (SkRect *bounds) const override
 

Additional Inherited Members

- Public Types inherited from SkPathEffect
enum  DashType { kNone_DashType , kDash_DashType }
 
- Public Types inherited from SkFlattenable
enum  Type {
  kSkColorFilter_Type , kSkBlender_Type , kSkDrawable_Type , kSkDrawLooper_Type ,
  kSkImageFilter_Type , kSkMaskFilter_Type , kSkPathEffect_Type , kSkShader_Type
}
 
typedef sk_sp< SkFlattenable >(* Factory) (SkReadBuffer &)
 
- Static Public Member Functions inherited from SkPathEffectBase
static sk_sp< SkPathEffectDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
static void RegisterFlattenables ()
 
- Static Public Member Functions inherited from SkPathEffect
static sk_sp< SkPathEffectMakeSum (sk_sp< SkPathEffect > first, sk_sp< SkPathEffect > second)
 
static sk_sp< SkPathEffectMakeCompose (sk_sp< SkPathEffect > outer, sk_sp< SkPathEffect > inner)
 
static SkFlattenable::Type GetFlattenableType ()
 
static sk_sp< SkPathEffectDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
- Static Public Member Functions inherited from SkFlattenable
static Factory NameToFactory (const char name[])
 
static const char * FactoryToName (Factory)
 
static void Register (const char name[], Factory)
 
static sk_sp< SkFlattenableDeserialize (Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
 

Detailed Description

Definition at line 14 of file SkTrimPE.h.

Constructor & Destructor Documentation

◆ SkTrimPE()

SkTrimPE::SkTrimPE ( SkScalar  startT,
SkScalar  stopT,
SkTrimPathEffect::Mode  mode 
)

Definition at line 63 of file SkTrimPathEffect.cpp.

64 : fStartT(startT), fStopT(stopT), fMode(mode) {}

Member Function Documentation

◆ computeFastBounds()

bool SkTrimPE::computeFastBounds ( SkRect bounds) const
inlineoverrideprivatevirtual

Implements SkPathEffectBase.

Definition at line 26 of file SkTrimPE.h.

26 {
27 // Trimming a path returns a subset of the input path so just return true and leave bounds
28 // unmodified
29 return true;
30 }

◆ flatten()

void SkTrimPE::flatten ( SkWriteBuffer ) const
overrideprotectedvirtual

Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()).

DEPRECATED public : will move to protected ... use serialize() instead

Reimplemented from SkFlattenable.

Definition at line 116 of file SkTrimPathEffect.cpp.

116 {
117 buffer.writeScalar(fStartT);
118 buffer.writeScalar(fStopT);
119 buffer.writeUInt(static_cast<uint32_t>(fMode));
120}
static const uint8_t buffer[]

◆ onFilterPath()

bool SkTrimPE::onFilterPath ( SkPath ,
const SkPath ,
SkStrokeRec ,
const SkRect ,
const SkMatrix  
) const
overrideprotectedvirtual

Filter the input path.

The CTM parameter is provided for path effects that can use the information. The output of path effects must always be in the original (input) coordinate system, regardless of whether the path effect uses the CTM or not.

Implements SkPathEffectBase.

Definition at line 66 of file SkTrimPathEffect.cpp.

67 {
68 if (fStartT >= fStopT) {
70 return true;
71 }
72
73 // First pass: compute the total len.
74 SkScalar len = 0;
75 SkPathMeasure meas(src, false);
76 do {
77 len += meas.getLength();
78 } while (meas.nextContour());
79
80 const auto arcStart = len * fStartT,
81 arcStop = len * fStopT;
82
83 // Second pass: actually add segments.
85 // Normal mode -> one span.
86 if (arcStart < arcStop) {
87 add_segments(src, arcStart, arcStop, dst);
88 }
89 } else {
90 // Inverted mode -> one logical span which wraps around at the end -> two actual spans.
91 // In order to preserve closed path continuity:
92 //
93 // 1) add the second/tail span first
94 //
95 // 2) skip the head span move-to for single-closed-contour paths
96
97 bool requires_moveto = true;
98 if (arcStop < len) {
99 // since we're adding the "tail" first, this is the total number of contours
100 const auto contour_count = add_segments(src, arcStop, len, dst);
101
102 // if the path consists of a single closed contour, we don't want to disconnect
103 // the two parts with a moveto.
104 if (contour_count == 1 && src.isLastContourClosed()) {
105 requires_moveto = false;
106 }
107 }
108 if (0 < arcStart) {
109 add_segments(src, 0, arcStart, dst, requires_moveto);
110 }
111 }
112
113 return true;
114}
#define SkASSERT(cond)
Definition SkAssert.h:116
float SkScalar
Definition extension.cpp:12

The documentation for this class was generated from the following files: