diff options
Diffstat (limited to 'src/core/SkPathEffect.cpp')
-rw-r--r-- | src/core/SkPathEffect.cpp | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp index 2905895..c3a24fc 100644 --- a/src/core/SkPathEffect.cpp +++ b/src/core/SkPathEffect.cpp @@ -19,19 +19,17 @@ #include "SkPath.h" #include "SkBuffer.h" -////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1) - : fPE0(pe0), fPE1(pe1) -{ + : fPE0(pe0), fPE1(pe1) { SkASSERT(pe0); SkASSERT(pe1); fPE0->ref(); fPE1->ref(); } -SkPairPathEffect::~SkPairPathEffect() -{ +SkPairPathEffect::~SkPairPathEffect() { fPE0->unref(); fPE1->unref(); } @@ -39,62 +37,63 @@ SkPairPathEffect::~SkPairPathEffect() /* Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] */ -void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer) -{ +void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer) { buffer.writeFlattenable(fPE0); buffer.writeFlattenable(fPE1); } -SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer) -{ +SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer) { fPE0 = (SkPathEffect*)buffer.readFlattenable(); fPE1 = (SkPathEffect*)buffer.readFlattenable(); } -////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// -bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width) -{ +bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, + SkScalar* width) { SkPath tmp; const SkPath* ptr = &src; - if (fPE1->filterPath(&tmp, src, width)) + if (fPE1->filterPath(&tmp, src, width)) { ptr = &tmp; + } return fPE0->filterPath(dst, *ptr, width); } -////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// -bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width) -{ +bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, + SkScalar* width) { // use bit-or so that we always call both, even if the first one succeeds return fPE0->filterPath(dst, src, width) | fPE1->filterPath(dst, src, width); } -///////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// #include "SkStroke.h" SkStrokePathEffect::SkStrokePathEffect(const SkPaint& paint) : fWidth(paint.getStrokeWidth()), fMiter(paint.getStrokeMiter()), - fStyle(SkToU8(paint.getStyle())), fJoin(SkToU8(paint.getStrokeJoin())), fCap(SkToU8(paint.getStrokeCap())) -{ + fStyle(SkToU8(paint.getStyle())), fJoin(SkToU8(paint.getStrokeJoin())), + fCap(SkToU8(paint.getStrokeCap())) { } -SkStrokePathEffect::SkStrokePathEffect(SkScalar width, SkPaint::Style style, SkPaint::Join join, SkPaint::Cap cap, SkScalar miter) - : fWidth(width), fMiter(miter), fStyle(SkToU8(style)), fJoin(SkToU8(join)), fCap(SkToU8(cap)) -{ - if (miter < 0) // signal they want the default +SkStrokePathEffect::SkStrokePathEffect(SkScalar width, SkPaint::Style style, + SkPaint::Join join, SkPaint::Cap cap, SkScalar miter) + : fWidth(width), fMiter(miter), fStyle(SkToU8(style)), + fJoin(SkToU8(join)), fCap(SkToU8(cap)) { + if (miter < 0) { // signal they want the default fMiter = SK_DefaultMiterLimit; + } } -bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width) -{ - if (fWidth < 0 || fStyle == SkPaint::kFill_Style) +bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src, + SkScalar* width) { + if (fWidth < 0 || fStyle == SkPaint::kFill_Style) { return false; + } - if (fStyle == SkPaint::kStroke_Style && fWidth == 0) // hairline - { + if (fStyle == SkPaint::kStroke_Style && fWidth == 0) { // hairline *width = 0; return true; } @@ -111,18 +110,15 @@ bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* wi return true; } -SkFlattenable::Factory SkStrokePathEffect::getFactory() -{ +SkFlattenable::Factory SkStrokePathEffect::getFactory() { return CreateProc; } -SkFlattenable* SkStrokePathEffect::CreateProc(SkFlattenableReadBuffer& buffer) -{ +SkFlattenable* SkStrokePathEffect::CreateProc(SkFlattenableReadBuffer& buffer) { return SkNEW_ARGS(SkStrokePathEffect, (buffer)); } -void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer) -{ +void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer) { buffer.writeScalar(fWidth); buffer.writeScalar(fMiter); buffer.write8(fStyle); @@ -130,8 +126,7 @@ void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer) buffer.write8(fCap); } -SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) -{ +SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) { fWidth = buffer.readScalar(); fMiter = buffer.readScalar(); fStyle = buffer.readU8(); @@ -139,4 +134,3 @@ SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) fCap = buffer.readU8(); } - |