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

Side by Side Diff: src/utils/SkEventTracer.cpp

Issue 302083003: Clean up SkOnce: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unused 1 == 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/ports/SkGlobalInitialization_default.cpp ('k') | src/utils/win/SkDWrite.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 2014 Google Inc. 2 * Copyright 2014 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 "SkEventTracer.h" 8 #include "SkEventTracer.h"
9 #include "SkOnce.h" 9 #include "SkOnce.h"
10 10
(...skipping 18 matching lines...) Expand all
29 static uint8_t no = 0; 29 static uint8_t no = 0;
30 return &no; 30 return &no;
31 }; 31 };
32 virtual const char* getCategoryGroupName( 32 virtual const char* getCategoryGroupName(
33 const uint8_t* categoryEnabledFlag) SK_OVERRIDE { 33 const uint8_t* categoryEnabledFlag) SK_OVERRIDE {
34 static const char* dummy = "dummy"; 34 static const char* dummy = "dummy";
35 return dummy; 35 return dummy;
36 }; 36 };
37 }; 37 };
38 38
39 SkEventTracer *SkEventTracer::gInstance; 39 SkEventTracer* SkEventTracer::gInstance;
40
41 static void intialiize_default_tracer(void *current_instance) {
42 if (NULL == current_instance) {
43 SkEventTracer::SetInstance(SkNEW(SkDefaultEventTracer));
44 }
45 }
46 40
47 static void cleanup_tracer() { 41 static void cleanup_tracer() {
48 // calling SetInstance will delete the existing instance. 42 // calling SetInstance will delete the existing instance.
49 SkEventTracer::SetInstance(NULL); 43 SkEventTracer::SetInstance(NULL);
50 } 44 }
51 45
46 static void intialize_default_tracer(SkEventTracer* current_instance) {
47 if (NULL == current_instance) {
48 SkEventTracer::SetInstance(SkNEW(SkDefaultEventTracer));
49 }
50 atexit(cleanup_tracer);
51 }
52
53
52 SkEventTracer* SkEventTracer::GetInstance() { 54 SkEventTracer* SkEventTracer::GetInstance() {
53 SK_DECLARE_STATIC_ONCE(once); 55 SK_DECLARE_STATIC_ONCE(once);
54 SkOnce(&once, 56 SkOnce(&once, intialize_default_tracer, SkEventTracer::gInstance);
55 intialiize_default_tracer,
56 SkEventTracer::gInstance,
57 cleanup_tracer);
58 SkASSERT(NULL != SkEventTracer::gInstance); 57 SkASSERT(NULL != SkEventTracer::gInstance);
59 return SkEventTracer::gInstance; 58 return SkEventTracer::gInstance;
60 } 59 }
OLDNEW
« no previous file with comments | « src/ports/SkGlobalInitialization_default.cpp ('k') | src/utils/win/SkDWrite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698