From 6f07665768dc84453316e7b2bbd6049576764cb1 Mon Sep 17 00:00:00 2001 From: mtklein Date: Tue, 13 Jan 2015 08:22:43 -0800 Subject: Simplify SkInstCnt This code requires fewer macros to use it (just one), has less code in macro definitions, and has simpler synchronization code (just atomic ints, no SkOnce, no SkMutex, etc.) A minor downside, we lose indentation and reverse-ordering in the final report: Leaked SkRefCntBase: 7 Leaked SkFontMgr: 1 Leaked SkWeakRefCnt: 1 Leaked SkTypeface: 1 Leaked SkFlattenable: 3 Leaked SkXfermode: 3 Leaked SkPathRef: 1 Leaked SkPixelRef: 1 Leaked SkMallocPixelRef: 1 becomes Leaked SkXfermode: 3 Leaked SkMallocPixelRef: 1 Leaked SkPixelRef: 1 Leaked SkPathRef: 1 Leaked SkFlattenable: 3 Leaked SkTypeface: 1 Leaked SkWeakRefCnt: 1 Leaked SkFontMgr: 1 Leaked SkRefCntBase: 7 This is motivated by wanting to land https://codereview.chromium.org/806473006/, which makes sure all static use of SkOnce are in global scope. The current implementation of SkInstCnt uses them in function scope, which isn't safe. BUG=skia: No public API changes. TBR=reed@google.com Review URL: https://codereview.chromium.org/841263004 --- src/core/SkInstCnt.cpp | 4 ++-- src/gpu/gl/GrGLCreateNullInterface.cpp | 6 +++--- src/gpu/gl/GrGLGpuProgramCache.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/core/SkInstCnt.cpp b/src/core/SkInstCnt.cpp index 2f9a57dc2b..0211b123ee 100644 --- a/src/core/SkInstCnt.cpp +++ b/src/core/SkInstCnt.cpp @@ -7,6 +7,6 @@ #include "SkInstCnt.h" -#if SK_ENABLE_INST_COUNT -bool gPrintInstCount = false; +#if SK_ENABLE_INST_COUNT && !defined(SKIA_DLL) // See SkInstCnt.h + bool gPrintInstCount = false; #endif diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp index 6275ced6fc..14919bb786 100644 --- a/src/gpu/gl/GrGLCreateNullInterface.cpp +++ b/src/gpu/gl/GrGLCreateNullInterface.cpp @@ -14,7 +14,7 @@ class BufferObj { public: - SK_DECLARE_INST_COUNT_ROOT(BufferObj); + SK_DECLARE_INST_COUNT(BufferObj); BufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) { } @@ -47,7 +47,7 @@ private: // This class maintains a sparsely populated array of buffer pointers. class BufferManager { public: - SK_DECLARE_INST_COUNT_ROOT(BufferManager); + SK_DECLARE_INST_COUNT(BufferManager); BufferManager() : fFreeListHead(kFreeListEnd) {} @@ -116,7 +116,7 @@ private: */ struct ThreadContext { public: - SK_DECLARE_INST_COUNT_ROOT(ThreadContext); + SK_DECLARE_INST_COUNT(ThreadContext); BufferManager fBufferManager; GrGLuint fCurrArrayBuffer; diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp index 688b22ed04..a9202215eb 100644 --- a/src/gpu/gl/GrGLGpuProgramCache.cpp +++ b/src/gpu/gl/GrGLGpuProgramCache.cpp @@ -23,7 +23,7 @@ SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, typedef GrGLProgramDataManager::UniformHandle UniformHandle; struct GrGLGpu::ProgramCache::Entry { - SK_DECLARE_INST_COUNT_ROOT(Entry); + SK_DECLARE_INST_COUNT(Entry); Entry() : fProgram(NULL), fLRUStamp(0) {} SkAutoTUnref fProgram; -- cgit v1.2.3