| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkPathEffect.h" | 9 #include "SkPathEffect.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 SkPairPathEffect::~SkPairPathEffect() { | 39 SkPairPathEffect::~SkPairPathEffect() { |
| 40 SkSafeUnref(fPE0); | 40 SkSafeUnref(fPE0); |
| 41 SkSafeUnref(fPE1); | 41 SkSafeUnref(fPE1); |
| 42 } | 42 } |
| 43 | 43 |
| 44 /* | 44 /* |
| 45 Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] | 45 Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] |
| 46 */ | 46 */ |
| 47 void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { | 47 void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { |
| 48 this->INHERITED::flatten(buffer); | |
| 49 buffer.writeFlattenable(fPE0); | 48 buffer.writeFlattenable(fPE0); |
| 50 buffer.writeFlattenable(fPE1); | 49 buffer.writeFlattenable(fPE1); |
| 51 } | 50 } |
| 52 | 51 |
| 52 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 53 SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) { | 53 SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) { |
| 54 fPE0 = buffer.readPathEffect(); | 54 fPE0 = buffer.readPathEffect(); |
| 55 fPE1 = buffer.readPathEffect(); | 55 fPE1 = buffer.readPathEffect(); |
| 56 // either of these may fail, so we have to check for nulls later on | 56 // either of these may fail, so we have to check for nulls later on |
| 57 } | 57 } |
| 58 #endif |
| 58 | 59 |
| 59 /////////////////////////////////////////////////////////////////////////////// | 60 /////////////////////////////////////////////////////////////////////////////// |
| 60 | 61 |
| 62 SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) { |
| 63 SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect()); |
| 64 SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect()); |
| 65 return SkComposePathEffect::Create(pe0, pe1); |
| 66 } |
| 67 |
| 61 bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, | 68 bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, |
| 62 SkStrokeRec* rec, const SkRect* cullRect) const { | 69 SkStrokeRec* rec, const SkRect* cullRect) const { |
| 63 // we may have failed to unflatten these, so we have to check | 70 // we may have failed to unflatten these, so we have to check |
| 64 if (!fPE0 || !fPE1) { | 71 if (!fPE0 || !fPE1) { |
| 65 return false; | 72 return false; |
| 66 } | 73 } |
| 67 | 74 |
| 68 SkPath tmp; | 75 SkPath tmp; |
| 69 const SkPath* ptr = &src; | 76 const SkPath* ptr = &src; |
| 70 | 77 |
| 71 if (fPE1->filterPath(&tmp, src, rec, cullRect)) { | 78 if (fPE1->filterPath(&tmp, src, rec, cullRect)) { |
| 72 ptr = &tmp; | 79 ptr = &tmp; |
| 73 } | 80 } |
| 74 return fPE0->filterPath(dst, *ptr, rec, cullRect); | 81 return fPE0->filterPath(dst, *ptr, rec, cullRect); |
| 75 } | 82 } |
| 76 | 83 |
| 77 /////////////////////////////////////////////////////////////////////////////// | 84 /////////////////////////////////////////////////////////////////////////////// |
| 78 | 85 |
| 86 SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 87 SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect()); |
| 88 SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect()); |
| 89 return SkSumPathEffect::Create(pe0, pe1); |
| 90 } |
| 91 |
| 79 bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, | 92 bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, |
| 80 SkStrokeRec* rec, const SkRect* cullRect) const { | 93 SkStrokeRec* rec, const SkRect* cullRect) const { |
| 81 // use bit-or so that we always call both, even if the first one succeeds | 94 // use bit-or so that we always call both, even if the first one succeeds |
| 82 return fPE0->filterPath(dst, src, rec, cullRect) | | 95 return fPE0->filterPath(dst, src, rec, cullRect) | |
| 83 fPE1->filterPath(dst, src, rec, cullRect); | 96 fPE1->filterPath(dst, src, rec, cullRect); |
| 84 } | 97 } |
| OLD | NEW |