diff options
-rw-r--r-- | bench/Benchmark.h | 4 | ||||
-rw-r--r-- | fuzz/Fuzz.h | 8 | ||||
-rw-r--r-- | fuzz/fuzz.cpp | 4 | ||||
-rw-r--r-- | gm/gm.h | 4 | ||||
-rw-r--r-- | gn/core.gni | 1 | ||||
-rw-r--r-- | tests/Test.h | 4 | ||||
-rw-r--r-- | tools/Registry.h (renamed from include/core/SkTRegistry.h) | 28 |
7 files changed, 27 insertions, 26 deletions
diff --git a/bench/Benchmark.h b/bench/Benchmark.h index 30c7aa9345..8fc75f8b8e 100644 --- a/bench/Benchmark.h +++ b/bench/Benchmark.h @@ -11,7 +11,7 @@ #include "SkPoint.h" #include "SkRefCnt.h" #include "SkString.h" -#include "SkTRegistry.h" +#include "../tools/Registry.h" #define DEF_BENCH3(code, N) \ static BenchRegistry gBench##N([](void*) -> Benchmark* { code; }); @@ -150,6 +150,6 @@ private: typedef SkRefCnt INHERITED; }; -typedef SkTRegistry<Benchmark*(*)(void*)> BenchRegistry; +typedef sk_tools::Registry<Benchmark*(*)(void*)> BenchRegistry; #endif diff --git a/fuzz/Fuzz.h b/fuzz/Fuzz.h index 800a9f1a83..e6399a8a79 100644 --- a/fuzz/Fuzz.h +++ b/fuzz/Fuzz.h @@ -9,7 +9,7 @@ #define Fuzz_DEFINED #include "SkData.h" -#include "SkTRegistry.h" +#include "../tools/Registry.h" #include "SkTypes.h" #include <cmath> @@ -126,9 +126,9 @@ struct Fuzzable { void (*fn)(Fuzz*); }; -#define DEF_FUZZ(name, f) \ - static void fuzz_##name(Fuzz*); \ - SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ +#define DEF_FUZZ(name, f) \ + static void fuzz_##name(Fuzz*); \ + sk_tools::Registry<Fuzzable> register_##name({#name, fuzz_##name}); \ static void fuzz_##name(Fuzz* f) #endif//Fuzz_DEFINED diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp index 1543c43428..bf3b88c262 100644 --- a/fuzz/fuzz.cpp +++ b/fuzz/fuzz.cpp @@ -135,7 +135,7 @@ static uint8_t calculate_option(SkData* bytes) { static void fuzz_api(sk_sp<SkData> bytes) { const char* name = FLAGS_name.isEmpty() ? "" : FLAGS_name[0]; - for (auto r = SkTRegistry<Fuzzable>::Head(); r; r = r->next()) { + for (auto r = sk_tools::Registry<Fuzzable>::Head(); r; r = r->next()) { auto fuzzable = r->factory(); if (0 == strcmp(name, fuzzable.name)) { SkDebugf("Fuzzing %s...\n", fuzzable.name); @@ -147,7 +147,7 @@ static void fuzz_api(sk_sp<SkData> bytes) { } SkDebugf("When using --type api, please choose an API to fuzz with --name/-n:\n"); - for (auto r = SkTRegistry<Fuzzable>::Head(); r; r = r->next()) { + for (auto r = sk_tools::Registry<Fuzzable>::Head(); r; r = r->next()) { auto fuzzable = r->factory(); SkDebugf("\t%s\n", fuzzable.name); } @@ -13,7 +13,7 @@ #include "SkPaint.h" #include "SkSize.h" #include "SkString.h" -#include "SkTRegistry.h" +#include "../tools/Registry.h" #include "sk_tool_utils.h" #include "SkClipOpPriv.h" @@ -130,7 +130,7 @@ namespace skiagm { SkMatrix fStarterMatrix; }; - typedef SkTRegistry<GM*(*)(void*)> GMRegistry; + typedef sk_tools::Registry<GM*(*)(void*)> GMRegistry; class SimpleGM : public skiagm::GM { public: diff --git a/gn/core.gni b/gn/core.gni index 11a218518e..e5d72b33fc 100644 --- a/gn/core.gni +++ b/gn/core.gni @@ -436,7 +436,6 @@ skia_core_sources = [ "$_include/core/SkStrokeRec.h", "$_include/core/SkSurface.h", "$_include/core/SkSwizzle.h", - "$_include/core/SkTRegistry.h", "$_include/core/SkTextBlob.h", "$_include/core/SkTime.h", "$_include/core/SkTLazy.h", diff --git a/tests/Test.h b/tests/Test.h index 5e6eb6d421..db2552b614 100644 --- a/tests/Test.h +++ b/tests/Test.h @@ -8,7 +8,7 @@ #define skiatest_Test_DEFINED #include "SkString.h" -#include "SkTRegistry.h" +#include "../tools/Registry.h" #include "SkTypes.h" #include "SkClipOpPriv.h" @@ -96,7 +96,7 @@ struct Test { TestProc proc; }; -typedef SkTRegistry<Test> TestRegistry; +typedef sk_tools::Registry<Test> TestRegistry; /* Use the following macros to make use of the skiatest classes, e.g. diff --git a/include/core/SkTRegistry.h b/tools/Registry.h index 0994c990dc..6a1e24a303 100644 --- a/include/core/SkTRegistry.h +++ b/tools/Registry.h @@ -1,4 +1,3 @@ - /* * Copyright 2009 The Android Open Source Project * @@ -6,25 +5,26 @@ * found in the LICENSE file. */ - -#ifndef SkTRegistry_DEFINED -#define SkTRegistry_DEFINED +#ifndef sk_tools_Registry_DEFINED +#define sk_tools_Registry_DEFINED #include "SkTypes.h" +namespace sk_tools { + /** Template class that registers itself (in the constructor) into a linked-list and provides a function-pointer. This can be used to auto-register a set of services, e.g. a set of image codecs. */ -template <typename T> class SkTRegistry : SkNoncopyable { +template <typename T> class Registry : SkNoncopyable { public: typedef T Factory; - explicit SkTRegistry(T fact) : fFact(fact) { + explicit Registry(T fact) : fFact(fact) { #ifdef SK_BUILD_FOR_ANDROID // work-around for double-initialization bug { - SkTRegistry* reg = gHead; + Registry* reg = gHead; while (reg) { if (reg == this) { return; @@ -37,19 +37,21 @@ public: gHead = this; } - static const SkTRegistry* Head() { return gHead; } + static const Registry* Head() { return gHead; } - const SkTRegistry* next() const { return fChain; } + const Registry* next() const { return fChain; } const Factory& factory() const { return fFact; } private: - Factory fFact; - SkTRegistry* fChain; + Factory fFact; + Registry* fChain; - static SkTRegistry* gHead; + static Registry* gHead; }; // The caller still needs to declare an instance of this somewhere -template <typename T> SkTRegistry<T>* SkTRegistry<T>::gHead; +template <typename T> Registry<T>* Registry<T>::gHead; + +} // namespace sk_tools #endif |