Revert of SK_DECLARE_STATIC_MUTEX -> static SkMutex (patchset #1 id:1 of https:/...
authorreed <reed@google.com>
Thu, 5 May 2016 00:12:46 +0000 (17:12 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 5 May 2016 00:12:46 +0000 (17:12 -0700)
Reason for revert:
broken the Mac and Linux builders, e.g.:

https://build.chromium.org/p/chromium/builders/Mac/builds/15151
https://build.chromium.org/p/chromium/builders/Linux%20x64/builds/19052

Original issue's description:
> SK_DECLARE_STATIC_MUTEX -> static SkMutex
>
> There's no need to use a macro to declare static SkMutexes any more
> (and there's likewise no need to restrict them to global scope).
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1948193002
>
> Committed: https://skia.googlesource.com/skia/+/5e56cfd3fa1041dbb83899844fb92fa9a2ef1009

TBR=mtklein@google.com,mtklein@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review-Url: https://codereview.chromium.org/1945353003

23 files changed:
dm/DM.cpp
dm/DMJsonWriter.cpp
include/private/SkMutex.h
src/core/SkDeviceProfile.cpp
src/core/SkPaint.cpp
src/core/SkResourceCache.cpp
src/core/SkTypeface.cpp
src/core/SkTypefaceCache.cpp
src/effects/gradients/SkGradientShader.cpp
src/fonts/SkTestScalerContext.cpp
src/lazy/SkDiscardableMemoryPool.cpp
src/pathops/SkPathOpsDebug.cpp
src/pathops/SkPathOpsOp.cpp
src/ports/SkFontConfigInterface_direct.cpp
src/ports/SkFontHost_FreeType.cpp
src/ports/SkFontHost_fontconfig.cpp
src/ports/SkFontHost_mac.cpp
src/ports/SkFontMgr_fontconfig.cpp
src/ports/SkTLS_win.cpp
src/views/SkEventSink.cpp
tests/PathOpsExtendedTest.cpp
tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp
tools/sk_tool_utils_font.cpp

index 0cf649e9d62ef64e734cf2b1228aefaac864afff..9dbd43adda05367aa7ec1fccbda964de73593d59 100644 (file)
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -104,7 +104,7 @@ static void info(const char* fmt) {
     }
 }
 
-static SkMutex gFailuresMutex;
+SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
 static SkTArray<SkString> gFailures;
 
 static void fail(const SkString& err) {
index 652c70b8cc72e9c2364da6e6337f059a230edef8..7bd8acd6d2d989e070c0d3a380ced8303f29c2af 100644 (file)
@@ -19,7 +19,7 @@
 namespace DM {
 
 SkTArray<JsonWriter::BitmapResult> gBitmapResults;
-static SkMutex gBitmapResultLock;
+SK_DECLARE_STATIC_MUTEX(gBitmapResultLock);
 
 void JsonWriter::AddBitmapResult(const BitmapResult& result) {
     SkAutoMutexAcquire lock(&gBitmapResultLock);
@@ -27,7 +27,7 @@ void JsonWriter::AddBitmapResult(const BitmapResult& result) {
 }
 
 SkTArray<skiatest::Failure> gFailures;
-static SkMutex gFailureLock;
+SK_DECLARE_STATIC_MUTEX(gFailureLock);
 
 void JsonWriter::AddTestFailure(const skiatest::Failure& failure) {
     SkAutoMutexAcquire lock(gFailureLock);
index 503b1e8efc15fd6e6e281e6ec71d022cd2385250..b9af00f8a8be02fc1e3b7794e23d761b1c94c761 100644 (file)
@@ -12,6 +12,9 @@
 #include "../private/SkThreadID.h"
 #include "SkTypes.h"
 
+// TODO: no need for this anymore.
+#define SK_DECLARE_STATIC_MUTEX(name) static SkMutex name;
+
 class SkMutex {
 public:
     constexpr SkMutex() = default;
index 272a710b2f3670a1120cf67dcb0b95099317e358..e1c10c87d77366ba578d2d392981bf436abf1302 100644 (file)
@@ -44,7 +44,7 @@ SkDeviceProfile* SkDeviceProfile::Create(float gammaExp,
     return new SkDeviceProfile(gammaExp, contrast, config, level);
 }
 
-static SkMutex gMutex;
+SK_DECLARE_STATIC_MUTEX(gMutex);
 static SkDeviceProfile* gDefaultProfile;
 static SkDeviceProfile* gGlobalProfile;
 
index c9fff0d3c239be3ca2df51f9b5d584ae9f74e941..67bbda16652ca13e043aab6d2b1bc7336e8dbc2c 100644 (file)
@@ -1457,7 +1457,7 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
  * cachedMaskGamma the caller must hold the gMaskGammaCacheMutex and continue
  * to hold it until the returned pointer is refed or forgotten.
  */
-static SkMutex gMaskGammaCacheMutex;
+SK_DECLARE_STATIC_MUTEX(gMaskGammaCacheMutex);
 
 static SkMaskGamma* gLinearMaskGamma = nullptr;
 static SkMaskGamma* gMaskGamma = nullptr;
index bab3dd707b15fca4df402a8933f74875daa4dca6..e465132288ad09e862f1aafae473ed090db35893 100644 (file)
@@ -542,7 +542,7 @@ void SkResourceCache::checkMessages() {
 
 ///////////////////////////////////////////////////////////////////////////////
 
-static SkMutex gMutex;
+SK_DECLARE_STATIC_MUTEX(gMutex);
 static SkResourceCache* gResourceCache = nullptr;
 
 /** Must hold gMutex when calling. */
index 1788759e3d8cd73f91e3237b266f82f7e1843b9e..75bb05c2b13cbfac283b36281850603e0206f3c0 100644 (file)
@@ -78,7 +78,7 @@ protected:
 
 }
 
-static SkMutex gCreateDefaultMutex;
+SK_DECLARE_STATIC_MUTEX(gCreateDefaultMutex);
 
 SkTypeface* SkTypeface::GetDefaultTypeface(Style style) {
     static SkOnce once[4];
index 8c53b7fc270afe9a40019ea9ff8dfe911e4571ba..05a7a8eb5f3beb187447952c9ea1b3bd8a9a98e1 100644 (file)
@@ -64,7 +64,7 @@ SkFontID SkTypefaceCache::NewFontID() {
     return sk_atomic_inc(&gFontID) + 1;
 }
 
-static SkMutex gMutex;
+SK_DECLARE_STATIC_MUTEX(gMutex);
 
 void SkTypefaceCache::Add(SkTypeface* face) {
     SkAutoMutexAcquire ama(gMutex);
index ffcbfdd9d2035fa878e02a21e5a7c39f1adbaa7f..fdb6e59e1ca56e52a1450e1400bb07ce0286930a 100644 (file)
@@ -625,7 +625,7 @@ SkGradientShaderBase::GradientShaderCache* SkGradientShaderBase::refCache(U8CPU
     return fCache;
 }
 
-static SkMutex gGradientCacheMutex;
+SK_DECLARE_STATIC_MUTEX(gGradientCacheMutex);
 /*
  *  Because our caller might rebuild the same (logically the same) gradient
  *  over and over, we'd like to return exactly the same "bitmap" if possible,
index f59bb0f8e6ba4f97c4f1b4778c38bb19d2db4913..a2748564a56cca6722d165c3fb224fee80712eb9 100644 (file)
@@ -43,7 +43,7 @@ SkTestFont::~SkTestFont() {
 #ifdef SK_DEBUG
 
 #include "SkMutex.h"
-static SkMutex gUsedCharsMutex;
+SK_DECLARE_STATIC_MUTEX(gUsedCharsMutex);
 
 #endif
 
index da7db529583234ff4b2fbb13b23ef281a85a0e9b..d6753def9d2263e84bc8d156c0e317616b5d4025 100644 (file)
@@ -244,7 +244,7 @@ SkDiscardableMemoryPool* SkDiscardableMemoryPool::Create(size_t size, SkMutex* m
     return new DiscardableMemoryPool(size, mutex);
 }
 
-static SkMutex gMutex;
+SK_DECLARE_STATIC_MUTEX(gMutex);
 
 SkDiscardableMemoryPool* SkGetGlobalDiscardableMemoryPool() {
     static SkOnce once;
index 1ee7b38e187030d648a925795df18b43d381b85b..546771e84c6be240e75837dd83f1707bd799e6ec 100644 (file)
@@ -267,7 +267,7 @@ static void show_op(SkPathOp op, const char* pathOne, const char* pathTwo) {
     SkDebugf("}\n");
 }
 
-static SkMutex gTestMutex;
+SK_DECLARE_STATIC_MUTEX(gTestMutex);
 
 void SkPathOpsDebug::ShowPath(const SkPath& a, const SkPath& b, SkPathOp shapeOp,
         const char* testName) {
@@ -646,7 +646,7 @@ void SkOpSegment::debugMissingCoincidence(const char* id, SkPathOpsDebug::Glitch
             }
             if (spanBase->segment() != opp && spanBase->containsCoinEnd(opp)) {
                 continue;
-            }
+            } 
             const SkOpPtT* priorPtT = nullptr, * priorStopPtT;
             // find prior span containing opp segment
             const SkOpSegment* priorOpp = nullptr;
@@ -786,11 +786,11 @@ void SkOpSegment::debugMoveMultiples(const char* id, SkPathOpsDebug::GlitchLog*
                     }
                     goto checkNextSpan;
                 }
-        tryNextSpan:
+        tryNextSpan: 
                 ;
             } while (oppTest != oppLast && (oppTest = oppTest->upCast()->next()));
         } while ((testPtT = testPtT->next()) != startPtT);
-checkNextSpan:
+checkNextSpan: 
         ;
     } while ((test = test->final() ? nullptr : test->upCast()->next()));
 }
@@ -958,7 +958,7 @@ void SkOpSegment::debugShowNewWinding(const char* fun, const SkOpSpan* span, int
 // loop looking for a pair of angle parts that are too close to be sorted
 /* This is called after other more simple intersection and angle sorting tests have been exhausted.
    This should be rarely called -- the test below is thorough and time consuming.
-   This checks the distance between start points; the distance between
+   This checks the distance between start points; the distance between 
 */
 #if DEBUG_ANGLE
 void SkOpAngle::debugCheckNearCoincidence() const {
@@ -996,7 +996,7 @@ void SkOpAngle::debugCheckNearCoincidence() const {
             SkDebugf("\n");
         }
         test = test->fNext;
-    } while (test->fNext != this);
+    } while (test->fNext != this); 
 }
 #endif
 
index 545d696a3608633ac2a5bc6a703ff98920418fb9..257cb8ee69b646bc127825e2a82c518794750137 100644 (file)
@@ -223,7 +223,7 @@ static void dump_op(const SkPath& one, const SkPath& two, SkPathOp op) {
     dump_path(file, two, false, true);
     fprintf(file, "    SkPath path2(path);\n");
     fprintf(file, "    testPathOp(reporter, path1, path2, (SkPathOp) %d, filename);\n", op);
-    fprintf(file, "}\n");
+    fprintf(file, "}\n");    
     fclose(file);
 }
 #endif
@@ -233,7 +233,7 @@ static void dump_op(const SkPath& one, const SkPath& two, SkPathOp op) {
 
 #include "SkMutex.h"
 
-static SkMutex debugWorstLoop;
+SK_DECLARE_STATIC_MUTEX(debugWorstLoop);
 
 SkOpGlobalState debugWorstState(nullptr, nullptr  SkDEBUGPARAMS(nullptr));
 
@@ -254,7 +254,7 @@ bool OpDebug(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result,
     SkOpGlobalState globalState(&coincidence, contourList  SkDEBUGPARAMS(testName));
 #if DEBUGGING_PATHOPS_FROM_HOST
     dump_op(one, two, op);
-#endif
+#endif    
 #if 0 && DEBUG_SHOW_TEST_NAME
     char* debugName = DEBUG_FILENAME_STRING;
     if (debugName && debugName[0]) {
index f2360020ad9a585c5b0c61678511357bad630556..d6fa96a46cfa5c418516a860edbfc9af9937a385 100644 (file)
@@ -32,7 +32,7 @@ namespace {
 
 // Fontconfig is not threadsafe before 2.10.91. Before that, we lock with a global mutex.
 // See https://bug.skia.org/1497 for background.
-static SkMutex gFCMutex;
+SK_DECLARE_STATIC_MUTEX(gFCMutex);
 
 #ifdef SK_DEBUG
 void* CreateThreadFcLocked() { return new bool(false); }
index 1cde6cbfbf428858d69e76b5f0b9e8344233da53..b53364eacb47eab195b7b6cc7269143736a62e3b 100644 (file)
@@ -145,7 +145,7 @@ private:
 
 struct SkFaceRec;
 
-static SkMutex gFTMutex;
+SK_DECLARE_STATIC_MUTEX(gFTMutex);
 static FreeTypeLibrary* gFTLibrary;
 static SkFaceRec* gFaceRecHead;
 
index 416173add9fba9ab8f73c44174e19d2fe2ee8e3b..0ffc26116f9880a86bf8c6ba43400eef2c76cf49 100644 (file)
@@ -10,7 +10,7 @@
 #include "SkMutex.h"
 #include "SkRefCnt.h"
 
-static SkMutex gFontConfigInterfaceMutex;
+SK_DECLARE_STATIC_MUTEX(gFontConfigInterfaceMutex);
 static SkFontConfigInterface* gFontConfigInterface;
 
 SkFontConfigInterface* SkFontConfigInterface::RefGlobal() {
index 6f0bbad6bd64c7d1dd29ea5e68793178bb54395f..8593b396117ced96e3a4414b2d069fe03e849ecb 100644 (file)
@@ -54,7 +54,7 @@
 #define USE_GLOBAL_MUTEX_FOR_CG_ACCESS
 
 #ifdef USE_GLOBAL_MUTEX_FOR_CG_ACCESS
-    static SkMutex gCGMutex;
+    SK_DECLARE_STATIC_MUTEX(gCGMutex);
     #define AUTO_CG_LOCK()  SkAutoMutexAcquire amc(gCGMutex)
 #else
     #define AUTO_CG_LOCK()
@@ -550,7 +550,7 @@ static SkTypeface* NewFromName(const char familyName[], const SkFontStyle& theSt
     return face;
 }
 
-static SkMutex gGetDefaultFaceMutex;
+SK_DECLARE_STATIC_MUTEX(gGetDefaultFaceMutex);
 static SkTypeface* GetDefaultFace() {
     SkAutoMutexAcquire ma(gGetDefaultFaceMutex);
 
index 32f10a491c9540707b2aac1556fe48cfbff09759..610a3001fb2c66e5df68e2fe08f0c34d7c0644f0 100644 (file)
@@ -62,7 +62,7 @@ namespace {
 
 // Fontconfig is not threadsafe before 2.10.91. Before that, we lock with a global mutex.
 // See https://bug.skia.org/1497 for background.
-static SkMutex gFCMutex;
+SK_DECLARE_STATIC_MUTEX(gFCMutex);
 
 #ifdef SK_DEBUG
 void* CreateThreadFcLocked() { return new bool(false); }
index 3f0084240886ff505943513eb725af34cf0e929a..8bc55a0f2cfe9c04bf15fd4015321773b400a31a 100644 (file)
@@ -12,7 +12,7 @@
 
 static bool gOnce = false;
 static DWORD gTlsIndex;
-static SkMutex gMutex;
+SK_DECLARE_STATIC_MUTEX(gMutex);
 
 void* SkTLS::PlatformGetSpecific(bool forceCreateTheSlot) {
     if (!forceCreateTheSlot && !gOnce) {
index 5345608969436b34f08e38fba95e16821fa47b49..1464fa0facea0a2aa3459d669abdfe67c3025d23 100644 (file)
@@ -257,7 +257,7 @@ SkEventSink* SkEventSink::FindSink(SkEventSinkID sinkID)
 #include "SkTDict.h"
 
 #define kMinStringBufferSize    128
-static SkMutex gNamedSinkMutex;
+SK_DECLARE_STATIC_MUTEX(gNamedSinkMutex);
 static SkTDict<SkEventSinkID>   gNamedSinkIDs(kMinStringBufferSize);
 
 /** Register a name/id pair with the system. If the name already exists,
index 27baa8c4b8ed15fc976cc42af86862ca7e0c56a1..c96cbcdae5ff11ddbf2285f9f2a862337d85a44d 100644 (file)
@@ -331,7 +331,7 @@ void ShowTestArray(const char* testName) {
     }
 }
 
-static SkMutex compareDebugOut3;
+SK_DECLARE_STATIC_MUTEX(compareDebugOut3);
 
 static int comparePaths(skiatest::Reporter* reporter, const char* testName, const SkPath& one,
         const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkBitmap& bitmap,
@@ -419,7 +419,7 @@ static void outputToStream(const char* pathStr, const char* pathPrefix, const ch
     outFile.flush();
 }
 
-static SkMutex simplifyDebugOut;
+SK_DECLARE_STATIC_MUTEX(simplifyDebugOut);
 
 bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& state,
                   const char* pathStr) {
@@ -578,7 +578,7 @@ bool testPathFailOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath&
     return true;
 }
 
-static SkMutex gMutex;
+SK_DECLARE_STATIC_MUTEX(gMutex);
 
 void initializeTests(skiatest::Reporter* reporter, const char* test) {
 #if 0  // doesn't work yet
index a6f62f0028dd1e6ccf086ce5cc164786f57fffd3..850adaaf257ace350b3962103bc05b5de5ead0cd 100644 (file)
@@ -142,7 +142,7 @@ static const GrGLInterface* create_command_buffer_interface() {
 
 // We use a poor man's garbage collector of EGLDisplays. They are only
 // terminated when there are no more EGLDisplays in use. See crbug.com/603223
-static SkMutex gDisplayMutex;
+SK_DECLARE_STATIC_MUTEX(gDisplayMutex);
 static int gActiveDisplayCnt;
 SkTArray<EGLDisplay> gRetiredDisplays;
 
index 67f86d1bb69dc8e1eb06abbe788307574562a7bc..adbfa1692b3191057e481591580baeed125b254c 100644 (file)
@@ -27,7 +27,7 @@ void release_portable_typefaces() {
     }
 }
 
-static SkMutex gTestFontMutex;
+SK_DECLARE_STATIC_MUTEX(gTestFontMutex);
 
 SkTypeface* create_font(const char* name, SkTypeface::Style style) {
     SkTestFontData* fontData = nullptr;