|
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 |
|
16 void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const { |
|
17 *dst = src; |
|
18 } |
|
19 |
|
20 bool SkPathEffect::asPoints(PointData* results, const SkPath& src, |
|
21 const SkStrokeRec&, const SkMatrix&, const SkRect*) const { |
|
22 return false; |
|
23 } |
|
24 |
|
25 /////////////////////////////////////////////////////////////////////////////// |
|
26 |
|
27 SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1) |
|
28 : fPE0(pe0), fPE1(pe1) { |
|
29 SkASSERT(pe0); |
|
30 SkASSERT(pe1); |
|
31 fPE0->ref(); |
|
32 fPE1->ref(); |
|
33 } |
|
34 |
|
35 SkPairPathEffect::~SkPairPathEffect() { |
|
36 SkSafeUnref(fPE0); |
|
37 SkSafeUnref(fPE1); |
|
38 } |
|
39 |
|
40 /* |
|
41 Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] |
|
42 */ |
|
43 void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { |
|
44 this->INHERITED::flatten(buffer); |
|
45 buffer.writeFlattenable(fPE0); |
|
46 buffer.writeFlattenable(fPE1); |
|
47 } |
|
48 |
|
49 SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) { |
|
50 fPE0 = buffer.readPathEffect(); |
|
51 fPE1 = buffer.readPathEffect(); |
|
52 // either of these may fail, so we have to check for nulls later on |
|
53 } |
|
54 |
|
55 /////////////////////////////////////////////////////////////////////////////// |
|
56 |
|
57 bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, |
|
58 SkStrokeRec* rec, const SkRect* cullRect) const { |
|
59 // we may have failed to unflatten these, so we have to check |
|
60 if (!fPE0 || !fPE1) { |
|
61 return false; |
|
62 } |
|
63 |
|
64 SkPath tmp; |
|
65 const SkPath* ptr = &src; |
|
66 |
|
67 if (fPE1->filterPath(&tmp, src, rec, cullRect)) { |
|
68 ptr = &tmp; |
|
69 } |
|
70 return fPE0->filterPath(dst, *ptr, rec, cullRect); |
|
71 } |
|
72 |
|
73 /////////////////////////////////////////////////////////////////////////////// |
|
74 |
|
75 bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, |
|
76 SkStrokeRec* rec, const SkRect* cullRect) const { |
|
77 // use bit-or so that we always call both, even if the first one succeeds |
|
78 return fPE0->filterPath(dst, src, rec, cullRect) | |
|
79 fPE1->filterPath(dst, src, rec, cullRect); |
|
80 } |