move SkTRegister.h into tools
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>
This commit is contained in:
parent
20d031a6ad
commit
ab273facbf
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
4
gm/gm.h
4
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:
|
||||
|
@ -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",
|
||||
|
@ -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.
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user