1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/core/SkPathEffect.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 +#include "SkPathEffect.h" 1.13 +#include "SkPath.h" 1.14 +#include "SkReadBuffer.h" 1.15 +#include "SkWriteBuffer.h" 1.16 + 1.17 +/////////////////////////////////////////////////////////////////////////////// 1.18 + 1.19 +void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const { 1.20 + *dst = src; 1.21 +} 1.22 + 1.23 +bool SkPathEffect::asPoints(PointData* results, const SkPath& src, 1.24 + const SkStrokeRec&, const SkMatrix&, const SkRect*) const { 1.25 + return false; 1.26 +} 1.27 + 1.28 +/////////////////////////////////////////////////////////////////////////////// 1.29 + 1.30 +SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1) 1.31 + : fPE0(pe0), fPE1(pe1) { 1.32 + SkASSERT(pe0); 1.33 + SkASSERT(pe1); 1.34 + fPE0->ref(); 1.35 + fPE1->ref(); 1.36 +} 1.37 + 1.38 +SkPairPathEffect::~SkPairPathEffect() { 1.39 + SkSafeUnref(fPE0); 1.40 + SkSafeUnref(fPE1); 1.41 +} 1.42 + 1.43 +/* 1.44 + Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] 1.45 +*/ 1.46 +void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { 1.47 + this->INHERITED::flatten(buffer); 1.48 + buffer.writeFlattenable(fPE0); 1.49 + buffer.writeFlattenable(fPE1); 1.50 +} 1.51 + 1.52 +SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) { 1.53 + fPE0 = buffer.readPathEffect(); 1.54 + fPE1 = buffer.readPathEffect(); 1.55 + // either of these may fail, so we have to check for nulls later on 1.56 +} 1.57 + 1.58 +/////////////////////////////////////////////////////////////////////////////// 1.59 + 1.60 +bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, 1.61 + SkStrokeRec* rec, const SkRect* cullRect) const { 1.62 + // we may have failed to unflatten these, so we have to check 1.63 + if (!fPE0 || !fPE1) { 1.64 + return false; 1.65 + } 1.66 + 1.67 + SkPath tmp; 1.68 + const SkPath* ptr = &src; 1.69 + 1.70 + if (fPE1->filterPath(&tmp, src, rec, cullRect)) { 1.71 + ptr = &tmp; 1.72 + } 1.73 + return fPE0->filterPath(dst, *ptr, rec, cullRect); 1.74 +} 1.75 + 1.76 +/////////////////////////////////////////////////////////////////////////////// 1.77 + 1.78 +bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, 1.79 + SkStrokeRec* rec, const SkRect* cullRect) const { 1.80 + // use bit-or so that we always call both, even if the first one succeeds 1.81 + return fPE0->filterPath(dst, src, rec, cullRect) | 1.82 + fPE1->filterPath(dst, src, rec, cullRect); 1.83 +}