SkMacros split from SkTypes.h

Change-Id: I383719ee181c6925ebf62ffc70e1c0f12ee7cf84
Reviewed-on: https://skia-review.googlesource.com/134326
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/gm/gm.h b/gm/gm.h
index a8190bf..c799532 100644
--- a/gm/gm.h
+++ b/gm/gm.h
@@ -8,14 +8,15 @@
 #ifndef skiagm_DEFINED
 #define skiagm_DEFINED
 
+#include "../tools/Registry.h"
 #include "SkBitmap.h"
 #include "SkCanvas.h"
+#include "SkClipOpPriv.h"
+#include "SkMacros.h"
 #include "SkMetaData.h"
 #include "SkPaint.h"
 #include "SkSize.h"
 #include "SkString.h"
-#include "../tools/Registry.h"
-#include "SkClipOpPriv.h"
 
 class SkAnimTimer;
 struct GrContextOptions;
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index d3b2e58..f42c5a3 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -18,6 +18,7 @@
 #ifndef SkCanvas_DEFINED
 #define SkCanvas_DEFINED
 
+#include "../private/SkMacros.h"
 #include "SkBlendMode.h"
 #include "SkClipOp.h"
 #include "SkDeque.h"
diff --git a/include/core/SkTime.h b/include/core/SkTime.h
index e9a8948..8a40c21 100644
--- a/include/core/SkTime.h
+++ b/include/core/SkTime.h
@@ -10,6 +10,7 @@
 #ifndef SkTime_DEFINED
 #define SkTime_DEFINED
 
+#include "../private/SkMacros.h"
 #include "SkTypes.h"
 
 class SkString;
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index db694e9..6586750 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -82,49 +82,6 @@
 // depend on SkString forward declaration below. Remove this once dependencies are fixed.
 class SkString;
 
-/*
- *  Usage:  SK_MACRO_CONCAT(a, b)   to construct the symbol ab
- *
- *  SK_MACRO_CONCAT_IMPL_PRIV just exists to make this work. Do not use directly
- *
- */
-#define SK_MACRO_CONCAT(X, Y)           SK_MACRO_CONCAT_IMPL_PRIV(X, Y)
-#define SK_MACRO_CONCAT_IMPL_PRIV(X, Y)  X ## Y
-
-/*
- *  Usage: SK_MACRO_APPEND_LINE(foo)    to make foo123, where 123 is the current
- *                                      line number. Easy way to construct
- *                                      unique names for local functions or
- *                                      variables.
- */
-#define SK_MACRO_APPEND_LINE(name)  SK_MACRO_CONCAT(name, __LINE__)
-
-/**
- * For some classes, it's almost always an error to instantiate one without a name, e.g.
- *   {
- *       SkAutoMutexAcquire(&mutex);
- *       <some code>
- *   }
- * In this case, the writer meant to hold mutex while the rest of the code in the block runs,
- * but instead the mutex is acquired and then immediately released.  The correct usage is
- *   {
- *       SkAutoMutexAcquire lock(&mutex);
- *       <some code>
- *   }
- *
- * To prevent callers from instantiating your class without a name, use SK_REQUIRE_LOCAL_VAR
- * like this:
- *   class classname {
- *       <your class>
- *   };
- *   #define classname(...) SK_REQUIRE_LOCAL_VAR(classname)
- *
- * This won't work with templates, and you must inline the class' constructors and destructors.
- * Take a look at SkAutoFree and SkAutoMalloc in this file for examples.
- */
-#define SK_REQUIRE_LOCAL_VAR(classname) \
-    static_assert(false, "missing name for " #classname)
-
 ///////////////////////////////////////////////////////////////////////
 
 /**
diff --git a/include/private/SkMacros.h b/include/private/SkMacros.h
new file mode 100644
index 0000000..3d79d52
--- /dev/null
+++ b/include/private/SkMacros.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkMacros_DEFINED
+#define SkMacros_DEFINED
+
+/*
+ *  Usage:  SK_MACRO_CONCAT(a, b)   to construct the symbol ab
+ *
+ *  SK_MACRO_CONCAT_IMPL_PRIV just exists to make this work. Do not use directly
+ *
+ */
+#define SK_MACRO_CONCAT(X, Y)           SK_MACRO_CONCAT_IMPL_PRIV(X, Y)
+#define SK_MACRO_CONCAT_IMPL_PRIV(X, Y)  X ## Y
+
+/*
+ *  Usage: SK_MACRO_APPEND_LINE(foo)    to make foo123, where 123 is the current
+ *                                      line number. Easy way to construct
+ *                                      unique names for local functions or
+ *                                      variables.
+ */
+#define SK_MACRO_APPEND_LINE(name)  SK_MACRO_CONCAT(name, __LINE__)
+
+/**
+ * For some classes, it's almost always an error to instantiate one without a name, e.g.
+ *   {
+ *       SkAutoMutexAcquire(&mutex);
+ *       <some code>
+ *   }
+ * In this case, the writer meant to hold mutex while the rest of the code in the block runs,
+ * but instead the mutex is acquired and then immediately released.  The correct usage is
+ *   {
+ *       SkAutoMutexAcquire lock(&mutex);
+ *       <some code>
+ *   }
+ *
+ * To prevent callers from instantiating your class without a name, use SK_REQUIRE_LOCAL_VAR
+ * like this:
+ *   class classname {
+ *       <your class>
+ *   };
+ *   #define classname(...) SK_REQUIRE_LOCAL_VAR(classname)
+ *
+ * This won't work with templates, and you must inline the class' constructors and destructors.
+ * Take a look at SkAutoFree and SkAutoMalloc in this file for examples.
+ */
+#define SK_REQUIRE_LOCAL_VAR(classname) \
+    static_assert(false, "missing name for " #classname)
+
+#endif  // SkMacros_DEFINED
diff --git a/include/private/SkMutex.h b/include/private/SkMutex.h
index 7cfdb11..9af23ad 100644
--- a/include/private/SkMutex.h
+++ b/include/private/SkMutex.h
@@ -8,6 +8,7 @@
 #ifndef SkMutex_DEFINED
 #define SkMutex_DEFINED
 
+#include "../private/SkMacros.h"
 #include "../private/SkSemaphore.h"
 #include "../private/SkThreadID.h"
 #include "SkTypes.h"
diff --git a/samplecode/SampleCode.h b/samplecode/SampleCode.h
index 053d682..3310d28 100644
--- a/samplecode/SampleCode.h
+++ b/samplecode/SampleCode.h
@@ -10,6 +10,7 @@
 
 #include "SkColor.h"
 #include "SkEvent.h"
+#include "SkMacros.h"
 #include "SkView.h"
 
 class SkAnimTimer;
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 31a407c..1cb1c74 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -11,6 +11,7 @@
 #include "SkColorSpace.h"
 #include "SkColorSpacePriv.h"
 #include "SkColorTable.h"
+#include "SkMacros.h"
 #include "SkMath.h"
 #include "SkOpts.h"
 #include "SkPngCodec.h"
diff --git a/src/core/SkAutoBlitterChoose.h b/src/core/SkAutoBlitterChoose.h
index b6c0433..40d438e 100644
--- a/src/core/SkAutoBlitterChoose.h
+++ b/src/core/SkAutoBlitterChoose.h
@@ -11,6 +11,7 @@
 #include "SkArenaAlloc.h"
 #include "SkBlitter.h"
 #include "SkDraw.h"
+#include "SkMacros.h"
 
 class SkMatrix;
 class SkPaint;
diff --git a/src/core/SkAutoMalloc.h b/src/core/SkAutoMalloc.h
index f5c8729..9c6dad9 100644
--- a/src/core/SkAutoMalloc.h
+++ b/src/core/SkAutoMalloc.h
@@ -8,8 +8,9 @@
 #ifndef SkAutoMalloc_DEFINED
 #define SkAutoMalloc_DEFINED
 
-#include "SkTypes.h"
+#include "SkMacros.h"
 #include "SkMalloc.h"
+#include "SkTypes.h"
 
 #include <memory>
 
diff --git a/src/core/SkDescriptor.h b/src/core/SkDescriptor.h
index 4bae7be..7f1939d 100644
--- a/src/core/SkDescriptor.h
+++ b/src/core/SkDescriptor.h
@@ -5,10 +5,10 @@
  * found in the LICENSE file.
  */
 
-
 #ifndef SkDescriptor_DEFINED
 #define SkDescriptor_DEFINED
 
+#include "SkMacros.h"
 #include "SkOpts.h"
 #include "SkTo.h"
 #include "SkTypes.h"
diff --git a/src/core/SkMask.h b/src/core/SkMask.h
index 337664d..89d8352 100644
--- a/src/core/SkMask.h
+++ b/src/core/SkMask.h
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2006 The Android Open Source Project
  *
@@ -6,11 +5,11 @@
  * found in the LICENSE file.
  */
 
-
 #ifndef SkMask_DEFINED
 #define SkMask_DEFINED
 
 #include "SkColorPriv.h"
+#include "SkMacros.h"
 #include "SkRect.h"
 #include "SkTemplates.h"
 
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index cabc116..605454b 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -11,6 +11,7 @@
 #include "SkCubicClipper.h"
 #include "SkData.h"
 #include "SkGeometry.h"
+#include "SkMacros.h"
 #include "SkMath.h"
 #include "SkMatrixPriv.h"
 #include "SkPathPriv.h"
diff --git a/src/core/SkRasterClip.h b/src/core/SkRasterClip.h
index e7d77ab..ff80824 100644
--- a/src/core/SkRasterClip.h
+++ b/src/core/SkRasterClip.h
@@ -8,8 +8,9 @@
 #ifndef SkRasterClip_DEFINED
 #define SkRasterClip_DEFINED
 
-#include "SkRegion.h"
 #include "SkAAClip.h"
+#include "SkMacros.h"
+#include "SkRegion.h"
 
 class SkRRect;
 
diff --git a/src/core/SkScopeExit.h b/src/core/SkScopeExit.h
index bdec7b3..4c9adcd 100644
--- a/src/core/SkScopeExit.h
+++ b/src/core/SkScopeExit.h
@@ -9,6 +9,8 @@
 #define SkScopeExit_DEFINED
 
 #include "SkTypes.h"
+#include "SkMacros.h"
+
 #include <functional>
 
 /** SkScopeExit calls a std:::function<void()> in its destructor. */
diff --git a/src/core/SkSharedMutex.h b/src/core/SkSharedMutex.h
index 21c9f46..33f1f10 100644
--- a/src/core/SkSharedMutex.h
+++ b/src/core/SkSharedMutex.h
@@ -9,6 +9,7 @@
 #define SkSharedLock_DEFINED
 
 #include "SkAtomics.h"
+#include "SkMacros.h"
 #include "SkSemaphore.h"
 #include "SkTypes.h"
 
diff --git a/src/gpu/vk/GrVkUtil.h b/src/gpu/vk/GrVkUtil.h
index 08eef1a..71cc5d4 100644
--- a/src/gpu/vk/GrVkUtil.h
+++ b/src/gpu/vk/GrVkUtil.h
@@ -10,9 +10,10 @@
 
 #include "GrColor.h"
 #include "GrTypes.h"
+#include "SkMacros.h"
+#include "ir/SkSLProgram.h"
 #include "vk/GrVkDefines.h"
 #include "vk/GrVkInterface.h"
-#include "ir/SkSLProgram.h"
 
 class GrVkGpu;
 
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index d98e68f..85e92ce 100644
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -16,6 +16,7 @@
 #include "SkFontDescriptor.h"
 #include "SkGlyph.h"
 #include "SkHRESULT.h"
+#include "SkMacros.h"
 #include "SkMakeUnique.h"
 #include "SkMaskGamma.h"
 #include "SkMatrix22.h"