Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: include/core/SkTRegistry.h

Issue 23453031: Rewrite SkTRegistry to take any trivially-copyable type. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: reed+scroggo Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkImageEncoder.h ('k') | src/images/SkImageDecoder_FactoryDefault.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTRegistry.h
diff --git a/include/core/SkTRegistry.h b/include/core/SkTRegistry.h
index 34fcffd5c51374cd422395fa7e547c287666a3b7..0994c990dccbe8625d59f06c705925ff2889cb21 100644
--- a/include/core/SkTRegistry.h
+++ b/include/core/SkTRegistry.h
@@ -16,11 +16,11 @@
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, typename P> class SkTRegistry : SkNoncopyable {
+template <typename T> class SkTRegistry : SkNoncopyable {
public:
- typedef T (*Factory)(P);
+ typedef T Factory;
- SkTRegistry(Factory fact) {
+ explicit SkTRegistry(T fact) : fFact(fact) {
#ifdef SK_BUILD_FOR_ANDROID
// work-around for double-initialization bug
{
@@ -33,15 +33,14 @@ public:
}
}
#endif
- fFact = fact;
fChain = gHead;
- gHead = this;
+ gHead = this;
}
static const SkTRegistry* Head() { return gHead; }
const SkTRegistry* next() const { return fChain; }
- Factory factory() const { return fFact; }
+ const Factory& factory() const { return fFact; }
private:
Factory fFact;
@@ -51,6 +50,6 @@ private:
};
// The caller still needs to declare an instance of this somewhere
-template <typename T, typename P> SkTRegistry<T, P>* SkTRegistry<T, P>::gHead;
+template <typename T> SkTRegistry<T>* SkTRegistry<T>::gHead;
#endif
« no previous file with comments | « include/core/SkImageEncoder.h ('k') | src/images/SkImageDecoder_FactoryDefault.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698