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 | 9 |
10 #include "SkBuffer.h" | 10 #include "SkBuffer.h" |
11 #include "SkErrorInternals.h" | 11 #include "SkErrorInternals.h" |
12 #include "SkMath.h" | 12 #include "SkMath.h" |
13 #include "SkPath.h" | 13 #include "SkPath.h" |
14 #include "SkPathRef.h" | 14 #include "SkPathRef.h" |
15 #include "SkRRect.h" | 15 #include "SkRRect.h" |
16 #include "SkThread.h" | 16 #include "SkThread.h" |
17 | 17 |
18 //////////////////////////////////////////////////////////////////////////// | |
19 | |
20 #if SK_DEBUG_PATH_REF | |
21 | |
22 SkPath::PathRefDebugRef::PathRefDebugRef(SkPathRef* pr, SkPath* owner) | |
23 : fPathRef(pr) | |
24 , fOwner(owner) | |
25 { | |
26 pr->addOwner(owner); | |
27 } | |
28 | |
29 SkPath::PathRefDebugRef::~PathRefDebugRef() { | |
30 fPathRef->removeOwner(fOwner); | |
31 } | |
32 | |
33 void SkPath::PathRefDebugRef::reset(SkPathRef* ref) { | |
34 bool diff = (ref != fPathRef.get()); | |
35 if (diff && NULL != fPathRef.get()) { | |
36 fPathRef.get()->removeOwner(fOwner); | |
37 } | |
38 fPathRef.reset(ref); | |
39 if (diff && NULL != fPathRef.get()) { | |
40 fPathRef.get()->addOwner(fOwner); | |
41 } | |
42 } | |
43 | |
44 void SkPath::PathRefDebugRef::swap(SkPath::PathRefDebugRef* other) { | |
45 if (other->fPathRef.get() != fPathRef.get()) { | |
46 other->fPathRef->removeOwner(other->fOwner); | |
47 other->fPathRef->addOwner(fOwner); | |
48 | |
49 fPathRef->removeOwner(fOwner); | |
50 fPathRef->addOwner(other->fOwner); | |
51 } | |
52 | |
53 fPathRef.swap(&other->fPathRef); | |
54 } | |
55 | |
56 SkPathRef* SkPath::PathRefDebugRef::get() const { return fPathRef.get(); } | |
57 | |
58 SkAutoTUnref<SkPathRef>::BlockRefType *SkPath::PathRefDebugRef::operator->() con
st { | |
59 return fPathRef.operator->(); | |
60 } | |
61 | |
62 SkPath::PathRefDebugRef::operator SkPathRef*() { | |
63 return fPathRef.operator SkPathRef *(); | |
64 } | |
65 | |
66 #endif | |
67 | |
68 //////////////////////////////////////////////////////////////////////////// | |
69 | |
70 | |
71 SK_DEFINE_INST_COUNT(SkPath); | 18 SK_DEFINE_INST_COUNT(SkPath); |
72 | 19 |
73 // This value is just made-up for now. When count is 4, calling memset was much | 20 // This value is just made-up for now. When count is 4, calling memset was much |
74 // slower than just writing the loop. This seems odd, and hopefully in the | 21 // slower than just writing the loop. This seems odd, and hopefully in the |
75 // future this we appear to have been a fluke... | 22 // future this we appear to have been a fluke... |
76 #define MIN_COUNT_FOR_MEMSET_TO_BE_FAST 16 | 23 #define MIN_COUNT_FOR_MEMSET_TO_BE_FAST 16 |
77 | 24 |
78 //////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////// |
79 | 26 |
80 /** | 27 /** |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 3. if we encounter Move without a preceeding Close, and forceClose is true,
goto #2 | 153 3. if we encounter Move without a preceeding Close, and forceClose is true,
goto #2 |
207 4. if we encounter Line | Quad | Cubic after Close, cons up a Move | 154 4. if we encounter Line | Quad | Cubic after Close, cons up a Move |
208 */ | 155 */ |
209 | 156 |
210 //////////////////////////////////////////////////////////////////////////// | 157 //////////////////////////////////////////////////////////////////////////// |
211 | 158 |
212 // flag to require a moveTo if we begin with something else, like lineTo etc. | 159 // flag to require a moveTo if we begin with something else, like lineTo etc. |
213 #define INITIAL_LASTMOVETOINDEX_VALUE ~0 | 160 #define INITIAL_LASTMOVETOINDEX_VALUE ~0 |
214 | 161 |
215 SkPath::SkPath() | 162 SkPath::SkPath() |
216 #if SK_DEBUG_PATH_REF | |
217 : fPathRef(SkPathRef::CreateEmpty(), this) | |
218 #else | |
219 : fPathRef(SkPathRef::CreateEmpty()) | 163 : fPathRef(SkPathRef::CreateEmpty()) |
220 #endif | |
221 #ifdef SK_BUILD_FOR_ANDROID | 164 #ifdef SK_BUILD_FOR_ANDROID |
222 , fGenerationID(0) | 165 , fGenerationID(0) |
223 #endif | 166 #endif |
224 { | 167 { |
225 this->resetFields(); | 168 this->resetFields(); |
226 } | 169 } |
227 | 170 |
228 void SkPath::resetFields() { | 171 void SkPath::resetFields() { |
229 //fPathRef is assumed to have been emptied by the caller. | 172 //fPathRef is assumed to have been emptied by the caller. |
230 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; | 173 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; |
231 fFillType = kWinding_FillType; | 174 fFillType = kWinding_FillType; |
232 fSegmentMask = 0; | 175 fSegmentMask = 0; |
233 fBoundsIsDirty = true; | 176 fBoundsIsDirty = true; |
234 fConvexity = kUnknown_Convexity; | 177 fConvexity = kUnknown_Convexity; |
235 fDirection = kUnknown_Direction; | 178 fDirection = kUnknown_Direction; |
236 fIsFinite = false; | 179 fIsFinite = false; |
237 fIsOval = false; | 180 fIsOval = false; |
238 #ifdef SK_BUILD_FOR_ANDROID | 181 #ifdef SK_BUILD_FOR_ANDROID |
239 GEN_ID_INC; | 182 GEN_ID_INC; |
240 fSourcePath = NULL; | 183 fSourcePath = NULL; |
241 #endif | 184 #endif |
242 } | 185 } |
243 | 186 |
244 SkPath::SkPath(const SkPath& that) | 187 SkPath::SkPath(const SkPath& that) |
245 #if SK_DEBUG_PATH_REF | |
246 : fPathRef(SkRef(that.fPathRef.get()), this) | |
247 #else | |
248 : fPathRef(SkRef(that.fPathRef.get())) | 188 : fPathRef(SkRef(that.fPathRef.get())) |
249 #endif | |
250 #ifdef SK_BUILD_FOR_ANDROID | 189 #ifdef SK_BUILD_FOR_ANDROID |
251 , fGenerationID(0) | 190 , fGenerationID(0) |
252 #endif | 191 #endif |
253 { | 192 { |
254 this->copyFields(that); | 193 this->copyFields(that); |
255 SkDEBUGCODE(that.validate();) | 194 SkDEBUGCODE(that.validate();) |
256 } | 195 } |
257 | 196 |
258 SkPath::~SkPath() { | 197 SkPath::~SkPath() { |
259 SkDEBUGCODE(this->validate();) | 198 SkDEBUGCODE(this->validate();) |
(...skipping 2791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3051 switch (this->getFillType()) { | 2990 switch (this->getFillType()) { |
3052 case SkPath::kEvenOdd_FillType: | 2991 case SkPath::kEvenOdd_FillType: |
3053 case SkPath::kInverseEvenOdd_FillType: | 2992 case SkPath::kInverseEvenOdd_FillType: |
3054 w &= 1; | 2993 w &= 1; |
3055 break; | 2994 break; |
3056 default: | 2995 default: |
3057 break; | 2996 break; |
3058 } | 2997 } |
3059 return SkToBool(w); | 2998 return SkToBool(w); |
3060 } | 2999 } |
OLD | NEW |