Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/core/SkPathRef.cpp

Issue 306063004: Revert of Port most uses of SkOnce to SkLazyPtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkMessageBus.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkLazyPtr.h" 9 #include "SkOnce.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
11 #include "SkPathRef.h" 11 #include "SkPathRef.h"
12 12
13 ////////////////////////////////////////////////////////////////////////////// 13 //////////////////////////////////////////////////////////////////////////////
14 SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef, 14 SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef,
15 int incReserveVerbs, 15 int incReserveVerbs,
16 int incReservePoints) 16 int incReservePoints)
17 { 17 {
18 if ((*pathRef)->unique()) { 18 if ((*pathRef)->unique()) {
19 (*pathRef)->incReserve(incReserveVerbs, incReservePoints); 19 (*pathRef)->incReserve(incReserveVerbs, incReservePoints);
20 } else { 20 } else {
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 static SkPathRef* gEmptyPathRef = NULL;
32 static void cleanup_gEmptyPathRef() { gEmptyPathRef->unref(); }
31 33
32 SkPathRef* SkPathRef::CreateEmptyImpl() { 34 void SkPathRef::CreateEmptyImpl(int) {
33 SkPathRef* p = SkNEW(SkPathRef); 35 gEmptyPathRef = SkNEW(SkPathRef);
34 p->computeBounds(); // Preemptively avoid a race to clear fBoundsIsDirty. 36 gEmptyPathRef->computeBounds(); // Preemptively avoid a race to clear fBoun dsIsDirty.
35 return p;
36 } 37 }
37 38
38 SkPathRef* SkPathRef::CreateEmpty() { 39 SkPathRef* SkPathRef::CreateEmpty() {
39 SK_DECLARE_STATIC_LAZY_PTR(SkPathRef, empty, CreateEmptyImpl); 40 SK_DECLARE_STATIC_ONCE(once);
40 return SkRef(empty.get()); 41 SkOnce(&once, SkPathRef::CreateEmptyImpl, 0, cleanup_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();
50 dst->reset(const_cast<SkPathRef*>(&src)); 52 dst->reset(const_cast<SkPathRef*>(&src));
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « src/core/SkMessageBus.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698