michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #include "SkPathEffect.h" michael@0: #include "SkPath.h" michael@0: #include "SkReadBuffer.h" michael@0: #include "SkWriteBuffer.h" michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const { michael@0: *dst = src; michael@0: } michael@0: michael@0: bool SkPathEffect::asPoints(PointData* results, const SkPath& src, michael@0: const SkStrokeRec&, const SkMatrix&, const SkRect*) const { michael@0: return false; michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1) michael@0: : fPE0(pe0), fPE1(pe1) { michael@0: SkASSERT(pe0); michael@0: SkASSERT(pe1); michael@0: fPE0->ref(); michael@0: fPE1->ref(); michael@0: } michael@0: michael@0: SkPairPathEffect::~SkPairPathEffect() { michael@0: SkSafeUnref(fPE0); michael@0: SkSafeUnref(fPE1); michael@0: } michael@0: michael@0: /* michael@0: Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] michael@0: */ michael@0: void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { michael@0: this->INHERITED::flatten(buffer); michael@0: buffer.writeFlattenable(fPE0); michael@0: buffer.writeFlattenable(fPE1); michael@0: } michael@0: michael@0: SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) { michael@0: fPE0 = buffer.readPathEffect(); michael@0: fPE1 = buffer.readPathEffect(); michael@0: // either of these may fail, so we have to check for nulls later on michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, michael@0: SkStrokeRec* rec, const SkRect* cullRect) const { michael@0: // we may have failed to unflatten these, so we have to check michael@0: if (!fPE0 || !fPE1) { michael@0: return false; michael@0: } michael@0: michael@0: SkPath tmp; michael@0: const SkPath* ptr = &src; michael@0: michael@0: if (fPE1->filterPath(&tmp, src, rec, cullRect)) { michael@0: ptr = &tmp; michael@0: } michael@0: return fPE0->filterPath(dst, *ptr, rec, cullRect); michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, michael@0: SkStrokeRec* rec, const SkRect* cullRect) const { michael@0: // use bit-or so that we always call both, even if the first one succeeds michael@0: return fPE0->filterPath(dst, src, rec, cullRect) | michael@0: fPE1->filterPath(dst, src, rec, cullRect); michael@0: }