move SkTRegister.h into tools
authorMike Reed <reed@google.com>
Wed, 11 Jan 2017 18:58:55 +0000 (13:58 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 11 Jan 2017 19:53:36 +0000 (19:53 +0000)
BUG=skia:

Change-Id: Ie7d4fac3024b361a281f456fec2b3a837e2bfe43
Reviewed-on: https://skia-review.googlesource.com/6881
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
bench/Benchmark.h
fuzz/Fuzz.h
fuzz/fuzz.cpp
gm/gm.h
gn/core.gni
tests/Test.h
tools/Registry.h [moved from include/core/SkTRegistry.h with 64% similarity]

index 30c7aa9..8fc75f8 100644 (file)
@@ -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
index 800a9f1..e6399a8 100644 (file)
@@ -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
index 1543c43..bf3b88c 100644 (file)
@@ -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);
     }
diff --git a/gm/gm.h b/gm/gm.h
index 0b26c16..2e4b602 100644 (file)
--- a/gm/gm.h
+++ b/gm/gm.h
@@ -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:
index 11a2185..e5d72b3 100644 (file)
@@ -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",
index 5e6eb6d..db2552b 100644 (file)
@@ -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.
similarity index 64%
rename from include/core/SkTRegistry.h
rename to tools/Registry.h
index 0994c99..6a1e24a 100644 (file)
@@ -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