1 2/* 3 * Copyright 2006 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#include "SkPathEffect.h" 10#include "SkPath.h" 11#include "SkReadBuffer.h" 12#include "SkWriteBuffer.h" 13 14/////////////////////////////////////////////////////////////////////////////// 15 16void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const { 17 *dst = src; 18} 19 20bool SkPathEffect::asPoints(PointData* results, const SkPath& src, 21 const SkStrokeRec&, const SkMatrix&, const SkRect*) const { 22 return false; 23} 24 25SkPathEffect::DashType SkPathEffect::asADash(DashInfo* info) const { 26 return kNone_DashType; 27} 28 29/////////////////////////////////////////////////////////////////////////////// 30 31SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1) 32 : fPE0(pe0), fPE1(pe1) { 33 SkASSERT(pe0); 34 SkASSERT(pe1); 35 fPE0->ref(); 36 fPE1->ref(); 37} 38 39SkPairPathEffect::~SkPairPathEffect() { 40 SkSafeUnref(fPE0); 41 SkSafeUnref(fPE1); 42} 43 44/* 45 Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] 46*/ 47void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { 48 this->INHERITED::flatten(buffer); 49 buffer.writeFlattenable(fPE0); 50 buffer.writeFlattenable(fPE1); 51} 52 53SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) { 54 fPE0 = buffer.readPathEffect(); 55 fPE1 = buffer.readPathEffect(); 56 // either of these may fail, so we have to check for nulls later on 57} 58 59/////////////////////////////////////////////////////////////////////////////// 60 61bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, 62 SkStrokeRec* rec, const SkRect* cullRect) const { 63 // we may have failed to unflatten these, so we have to check 64 if (!fPE0 || !fPE1) { 65 return false; 66 } 67 68 SkPath tmp; 69 const SkPath* ptr = &src; 70 71 if (fPE1->filterPath(&tmp, src, rec, cullRect)) { 72 ptr = &tmp; 73 } 74 return fPE0->filterPath(dst, *ptr, rec, cullRect); 75} 76 77/////////////////////////////////////////////////////////////////////////////// 78 79bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, 80 SkStrokeRec* rec, const SkRect* cullRect) const { 81 // use bit-or so that we always call both, even if the first one succeeds 82 return fPE0->filterPath(dst, src, rec, cullRect) | 83 fPE1->filterPath(dst, src, rec, cullRect); 84} 85