OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBuffer.h" | 8 #include "SkBuffer.h" |
| 9 #include "SkOnce.h" |
9 #include "SkPath.h" | 10 #include "SkPath.h" |
10 #include "SkPathRef.h" | 11 #include "SkPathRef.h" |
11 | 12 |
12 SK_DEFINE_INST_COUNT(SkPathRef); | 13 SK_DEFINE_INST_COUNT(SkPathRef); |
13 | 14 |
14 ////////////////////////////////////////////////////////////////////////////// | 15 ////////////////////////////////////////////////////////////////////////////// |
15 SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef, | 16 SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef, |
16 int incReserveVerbs, | 17 int incReserveVerbs, |
17 int incReservePoints) | 18 int incReservePoints) |
18 { | 19 { |
(...skipping 10 matching lines...) Expand all Loading... |
29 } | 30 } |
30 | 31 |
31 SkPoint* SkPathRef::Editor::growForConic(SkScalar w) { | 32 SkPoint* SkPathRef::Editor::growForConic(SkScalar w) { |
32 SkDEBUGCODE(fPathRef->validate();) | 33 SkDEBUGCODE(fPathRef->validate();) |
33 SkPoint* pts = fPathRef->growForVerb(SkPath::kConic_Verb); | 34 SkPoint* pts = fPathRef->growForVerb(SkPath::kConic_Verb); |
34 *fPathRef->fConicWeights.append() = w; | 35 *fPathRef->fConicWeights.append() = w; |
35 return pts; | 36 return pts; |
36 } | 37 } |
37 | 38 |
38 ////////////////////////////////////////////////////////////////////////////// | 39 ////////////////////////////////////////////////////////////////////////////// |
| 40 void SkPathRef::CreateEmptyImpl(SkPathRef** empty) { |
| 41 *empty = SkNEW(SkPathRef); |
| 42 (*empty)->computeBounds(); // Preemptively avoid a race to clear fBoundsIsD
irty. |
| 43 } |
| 44 |
| 45 SkPathRef* SkPathRef::CreateEmpty() { |
| 46 static SkPathRef* gEmptyPathRef; |
| 47 SK_DECLARE_STATIC_ONCE(once); |
| 48 SkOnce(&once, SkPathRef::CreateEmptyImpl, &gEmptyPathRef); |
| 49 return SkRef(gEmptyPathRef); |
| 50 } |
| 51 |
39 void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst, | 52 void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst, |
40 const SkPathRef& src, | 53 const SkPathRef& src, |
41 const SkMatrix& matrix) { | 54 const SkMatrix& matrix) { |
42 SkDEBUGCODE(src.validate();) | 55 SkDEBUGCODE(src.validate();) |
43 if (matrix.isIdentity()) { | 56 if (matrix.isIdentity()) { |
44 if (*dst != &src) { | 57 if (*dst != &src) { |
45 src.ref(); | 58 src.ref(); |
46 dst->reset(const_cast<SkPathRef*>(&src)); | 59 dst->reset(const_cast<SkPathRef*>(&src)); |
47 SkDEBUGCODE((*dst)->validate();) | 60 SkDEBUGCODE((*dst)->validate();) |
48 } | 61 } |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero); | 329 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero); |
317 if (!fPoints[i].isFinite()) { | 330 if (!fPoints[i].isFinite()) { |
318 isFinite = false; | 331 isFinite = false; |
319 } | 332 } |
320 } | 333 } |
321 SkASSERT(SkToBool(fIsFinite) == isFinite); | 334 SkASSERT(SkToBool(fIsFinite) == isFinite); |
322 } | 335 } |
323 #endif | 336 #endif |
324 } | 337 } |
325 #endif | 338 #endif |
OLD | NEW |