#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; });
typedef SkRefCnt INHERITED;
};
-typedef SkTRegistry<Benchmark*(*)(void*)> BenchRegistry;
+typedef sk_tools::Registry<Benchmark*(*)(void*)> BenchRegistry;
#endif
#define Fuzz_DEFINED
#include "SkData.h"
-#include "SkTRegistry.h"
+#include "../tools/Registry.h"
#include "SkTypes.h"
#include <cmath>
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
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);
}
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);
}
#include "SkPaint.h"
#include "SkSize.h"
#include "SkString.h"
-#include "SkTRegistry.h"
+#include "../tools/Registry.h"
#include "sk_tool_utils.h"
#include "SkClipOpPriv.h"
SkMatrix fStarterMatrix;
};
- typedef SkTRegistry<GM*(*)(void*)> GMRegistry;
+ typedef sk_tools::Registry<GM*(*)(void*)> GMRegistry;
class SimpleGM : public skiagm::GM {
public:
"$_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",
#define skiatest_Test_DEFINED
#include "SkString.h"
-#include "SkTRegistry.h"
+#include "../tools/Registry.h"
#include "SkTypes.h"
#include "SkClipOpPriv.h"
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.
-
/*
* Copyright 2009 The Android Open Source Project
*
* 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;
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