| 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 "SkOnce.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 SkPathRef* copy = SkNEW(SkPathRef); | 21 SkPathRef* copy = SkNEW(SkPathRef); |
| 22 copy->copy(**pathRef, incReserveVerbs, incReservePoints); | 22 copy->copy(**pathRef, incReserveVerbs, incReservePoints); |
| 23 pathRef->reset(copy); | 23 pathRef->reset(copy); |
| 24 } | 24 } |
| 25 fPathRef = *pathRef; | 25 fPathRef = *pathRef; |
| 26 fPathRef->fGenerationID = 0; | 26 fPathRef->fGenerationID = 0; |
| 27 SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);) | 27 SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);) |
| 28 } | 28 } |
| 29 | 29 |
| 30 ////////////////////////////////////////////////////////////////////////////// | 30 ////////////////////////////////////////////////////////////////////////////// |
| 31 void SkPathRef::CreateEmptyImpl(SkPathRef** empty) { | 31 static SkPathRef* gEmptyPathRef = NULL; |
| 32 *empty = SkNEW(SkPathRef); | 32 static void cleanup_gEmptyPathRef() { gEmptyPathRef->unref(); } |
| 33 (*empty)->computeBounds(); // Preemptively avoid a race to clear fBoundsIsD
irty. | 33 |
| 34 void SkPathRef::CreateEmptyImpl(int) { |
| 35 gEmptyPathRef = SkNEW(SkPathRef); |
| 36 gEmptyPathRef->computeBounds(); // Preemptively avoid a race to clear fBoun
dsIsDirty. |
| 34 } | 37 } |
| 35 | 38 |
| 36 SkPathRef* SkPathRef::CreateEmpty() { | 39 SkPathRef* SkPathRef::CreateEmpty() { |
| 37 static SkPathRef* gEmptyPathRef; | |
| 38 SK_DECLARE_STATIC_ONCE(once); | 40 SK_DECLARE_STATIC_ONCE(once); |
| 39 SkOnce(&once, SkPathRef::CreateEmptyImpl, &gEmptyPathRef); | 41 SkOnce(&once, SkPathRef::CreateEmptyImpl, 0, cleanup_gEmptyPathRef); |
| 40 return SkRef(gEmptyPathRef); | 42 return SkRef(gEmptyPathRef); |
| 41 } | 43 } |
| 42 | 44 |
| 43 void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst, | 45 void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst, |
| 44 const SkPathRef& src, | 46 const SkPathRef& src, |
| 45 const SkMatrix& matrix) { | 47 const SkMatrix& matrix) { |
| 46 SkDEBUGCODE(src.validate();) | 48 SkDEBUGCODE(src.validate();) |
| 47 if (matrix.isIdentity()) { | 49 if (matrix.isIdentity()) { |
| 48 if (*dst != &src) { | 50 if (*dst != &src) { |
| 49 src.ref(); | 51 src.ref(); |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 break; | 483 break; |
| 482 default: | 484 default: |
| 483 SkDEBUGFAIL("Unknown Verb"); | 485 SkDEBUGFAIL("Unknown Verb"); |
| 484 break; | 486 break; |
| 485 } | 487 } |
| 486 } | 488 } |
| 487 SkASSERT(mask == fSegmentMask); | 489 SkASSERT(mask == fSegmentMask); |
| 488 #endif // SK_DEBUG_PATH | 490 #endif // SK_DEBUG_PATH |
| 489 } | 491 } |
| 490 #endif | 492 #endif |
| OLD | NEW |