diff --git a/gn/core.gni b/gn/core.gni index 6466bf2cc0..7328e36781 100644 --- a/gn/core.gni +++ b/gn/core.gni @@ -461,6 +461,7 @@ skia_core_sources = [ "$_include/private/SkFloatingPoint.h", "$_include/private/SkHalf.h", "$_include/private/SkIDChangeListener.h", + "$_include/private/SkMacros.h", "$_include/private/SkMalloc.h", "$_include/private/SkMutex.h", "$_include/private/SkNoncopyable.h", diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 9ea55edb9d..da86d5c21b 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -2850,7 +2850,4 @@ private: SkAutoCanvasRestore& operator=(const SkAutoCanvasRestore&) = delete; }; -// Private -#define SkAutoCanvasRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoCanvasRestore) - #endif diff --git a/include/core/SkTime.h b/include/core/SkTime.h index 1f033ef3ad..55b823a42d 100644 --- a/include/core/SkTime.h +++ b/include/core/SkTime.h @@ -57,6 +57,5 @@ private: const char* fLabel; double fNow; }; -#define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime) #endif diff --git a/include/private/SkMacros.h b/include/private/SkMacros.h index a68193228f..59f81b2a2b 100644 --- a/include/private/SkMacros.h +++ b/include/private/SkMacros.h @@ -24,32 +24,6 @@ */ #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); - * - * } - * 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); - * - * } - * - * To prevent callers from instantiating your class without a name, use SK_REQUIRE_LOCAL_VAR - * like this: - * class classname { - * - * }; - * #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) - //////////////////////////////////////////////////////////////////////////////// // Can be used to bracket data types that must be dense, e.g. hash keys. diff --git a/include/private/SkMutex.h b/include/private/SkMutex.h index a9af46fdc1..7f65975ecc 100644 --- a/include/private/SkMutex.h +++ b/include/private/SkMutex.h @@ -47,6 +47,4 @@ private: SkMutex& fMutex; }; -#define SkAutoMutexExclusive(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexExclusive) - #endif // SkMutex_DEFINED diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp index df77b3aac0..c2e66155ad 100644 --- a/src/codec/SkPngCodec.cpp +++ b/src/codec/SkPngCodec.cpp @@ -127,7 +127,6 @@ private: fInfo_ptr = nullptr; } }; -#define AutoCleanPng(...) SK_REQUIRE_LOCAL_VAR(AutoCleanPng) static inline bool is_chunk(const png_byte* chunk, const char* tag) { return memcmp(chunk + 4, tag, 4) == 0; diff --git a/src/core/SkAutoBlitterChoose.h b/src/core/SkAutoBlitterChoose.h index 98c76f3a1b..9be6e677fe 100644 --- a/src/core/SkAutoBlitterChoose.h +++ b/src/core/SkAutoBlitterChoose.h @@ -54,6 +54,5 @@ private: SkSTArenaAlloc fAlloc; }; -#define SkAutoBlitterChoose(...) SK_REQUIRE_LOCAL_VAR(SkAutoBlitterChoose) #endif diff --git a/src/core/SkAutoMalloc.h b/src/core/SkAutoMalloc.h index 4be8ddb03e..7587ae6380 100644 --- a/src/core/SkAutoMalloc.h +++ b/src/core/SkAutoMalloc.h @@ -78,7 +78,6 @@ private: std::unique_ptr fPtr; size_t fSize; // can be larger than the requested size (see kReuse) }; -#define SkAutoMalloc(...) SK_REQUIRE_LOCAL_VAR(SkAutoMalloc) /** * Manage an allocated block of memory. If the requested size is <= kSizeRequested (or slightly diff --git a/src/core/SkMask.h b/src/core/SkMask.h index 29ae48e6ed..a3fe82e123 100644 --- a/src/core/SkMask.h +++ b/src/core/SkMask.h @@ -237,7 +237,7 @@ template <> struct SkMask::AlphaIter { * Stack class used to manage the fImage buffer in a SkMask. * When this object loses scope, the buffer is freed with SkMask::FreeImage(). */ -using SkAutoMaskFreeImage = std::unique_ptr>; -#define SkAutoMaskFreeImage(...) SK_REQUIRE_LOCAL_VAR(SkAutoMaskFreeImage) +using SkAutoMaskFreeImage = + std::unique_ptr>; #endif diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 2056256a65..8e6ecf910b 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -77,7 +77,6 @@ private: SkPath* fPath; SkPathPriv::FirstDirection fSaved; }; -#define SkAutoDisableDirectionCheck(...) SK_REQUIRE_LOCAL_VAR(SkAutoDisableDirectionCheck) /* This class's constructor/destructor bracket a path editing operation. It is used when we know the bounds of the amount we are going to add to the path @@ -121,7 +120,6 @@ private: bool fDegenerate; bool fEmpty; }; -#define SkAutoPathBoundsUpdate(...) SK_REQUIRE_LOCAL_VAR(SkAutoPathBoundsUpdate) //////////////////////////////////////////////////////////////////////////// diff --git a/src/core/SkRasterClip.h b/src/core/SkRasterClip.h index 4bb2b52708..10215a2067 100644 --- a/src/core/SkRasterClip.h +++ b/src/core/SkRasterClip.h @@ -205,7 +205,6 @@ public: private: const SkRasterClip& fRC; }; -#define SkAutoRasterClipValidate(...) SK_REQUIRE_LOCAL_VAR(SkAutoRasterClipValidate) #ifdef SK_DEBUG #define AUTO_RASTERCLIP_VALIDATE(rc) SkAutoRasterClipValidate arcv(rc) diff --git a/src/core/SkSharedMutex.h b/src/core/SkSharedMutex.h index 2544ee605a..c975d0bd27 100644 --- a/src/core/SkSharedMutex.h +++ b/src/core/SkSharedMutex.h @@ -83,8 +83,6 @@ private: SkSharedMutex& fLock; }; -#define SkAutoSharedMutexExclusive(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexExclusive) - class SK_SCOPED_CAPABILITY SkAutoSharedMutexShared { public: explicit SkAutoSharedMutexShared(SkSharedMutex& lock) SK_ACQUIRE_SHARED(lock) @@ -101,6 +99,4 @@ private: SkSharedMutex& fLock; }; -#define SkAutoSharedMutexShared(...) SK_REQUIRE_LOCAL_VAR(SkAutoSharedMutexShared) - #endif // SkSharedLock_DEFINED diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index 0ee7d3a517..82e88f3358 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -231,7 +231,6 @@ private: HFONT fFont; HFONT fSavefont; }; -#define SkAutoHDC(...) SK_REQUIRE_LOCAL_VAR(SkAutoHDC) class LogFontTypeface : public SkTypeface { public: