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

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

Issue 132803005: SkOnce: add option to call another cleanup function once at exit. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add static Created 6 years, 10 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/SkData.cpp ('k') | src/core/SkScaledImageCache.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 "SkOnce.h" 9 #include "SkOnce.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 10 matching lines...) Expand all
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
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/SkData.cpp ('k') | src/core/SkScaledImageCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698