aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-01-22 17:41:57 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-01-22 17:41:57 +0000
commita70ba36c97b4c0e12f1a5ed5b80d7bd31e5cb6ff (patch)
tree845857a8a0e183c17c3b9ae50cc6bdc593c7def1 /bench
parent7b830a1d2728eb20be09406fcfe23871e1a61308 (diff)
remove duplicate SkTRegistry definition
git-svn-id: http://skia.googlecode.com/svn/trunk@78 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r--bench/RectBench.cpp37
-rw-r--r--bench/SkBenchmark.h26
-rw-r--r--bench/main.cpp9
3 files changed, 22 insertions, 50 deletions
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp
index 13239f1500..ba01375b82 100644
--- a/bench/RectBench.cpp
+++ b/bench/RectBench.cpp
@@ -3,6 +3,7 @@
#include "SkPaint.h"
#include "SkRandom.h"
#include "SkString.h"
+#include "SkTRegistry.h"
class RectBench : public SkBenchmark {
public:
@@ -106,29 +107,29 @@ protected:
virtual const char* onGetName() { return fName; }
};
-static SkBenchmark* RectFactory1() { return SkNEW_ARGS(RectBench, (1)); }
-static SkBenchmark* RectFactory2() { return SkNEW_ARGS(RectBench, (3)); }
-static SkBenchmark* OvalFactory1() { return SkNEW_ARGS(OvalBench, (1)); }
-static SkBenchmark* OvalFactory2() { return SkNEW_ARGS(OvalBench, (3)); }
-static SkBenchmark* RRectFactory1() { return SkNEW_ARGS(RRectBench, (1)); }
-static SkBenchmark* RRectFactory2() { return SkNEW_ARGS(RRectBench, (3)); }
-static SkBenchmark* PointsFactory() {
+static SkBenchmark* RectFactory1(void*) { return SkNEW_ARGS(RectBench, (1)); }
+static SkBenchmark* RectFactory2(void*) { return SkNEW_ARGS(RectBench, (3)); }
+static SkBenchmark* OvalFactory1(void*) { return SkNEW_ARGS(OvalBench, (1)); }
+static SkBenchmark* OvalFactory2(void*) { return SkNEW_ARGS(OvalBench, (3)); }
+static SkBenchmark* RRectFactory1(void*) { return SkNEW_ARGS(RRectBench, (1)); }
+static SkBenchmark* RRectFactory2(void*) { return SkNEW_ARGS(RRectBench, (3)); }
+static SkBenchmark* PointsFactory(void*) {
return SkNEW_ARGS(PointsBench, (SkCanvas::kPoints_PointMode, "points"));
}
-static SkBenchmark* LinesFactory() {
+static SkBenchmark* LinesFactory(void*) {
return SkNEW_ARGS(PointsBench, (SkCanvas::kLines_PointMode, "lines"));
}
-static SkBenchmark* PolygonFactory() {
+static SkBenchmark* PolygonFactory(void*) {
return SkNEW_ARGS(PointsBench, (SkCanvas::kPolygon_PointMode, "polygon"));
}
-static SkTRegistry<SkBenchmark> gRectReg1(RectFactory1);
-static SkTRegistry<SkBenchmark> gRectReg2(RectFactory2);
-static SkTRegistry<SkBenchmark> gOvalReg1(OvalFactory1);
-static SkTRegistry<SkBenchmark> gOvalReg2(OvalFactory2);
-static SkTRegistry<SkBenchmark> gRRectReg1(RRectFactory1);
-static SkTRegistry<SkBenchmark> gRRectReg2(RRectFactory2);
-static SkTRegistry<SkBenchmark> gPointsReg(PointsFactory);
-static SkTRegistry<SkBenchmark> gLinesReg(LinesFactory);
-static SkTRegistry<SkBenchmark> gPolygonReg(PolygonFactory);
+static SkTRegistry<SkBenchmark*, void*> gRectReg1(RectFactory1);
+static SkTRegistry<SkBenchmark*, void*> gRectReg2(RectFactory2);
+static SkTRegistry<SkBenchmark*, void*> gOvalReg1(OvalFactory1);
+static SkTRegistry<SkBenchmark*, void*> gOvalReg2(OvalFactory2);
+static SkTRegistry<SkBenchmark*, void*> gRRectReg1(RRectFactory1);
+static SkTRegistry<SkBenchmark*, void*> gRRectReg2(RRectFactory2);
+static SkTRegistry<SkBenchmark*, void*> gPointsReg(PointsFactory);
+static SkTRegistry<SkBenchmark*, void*> gLinesReg(LinesFactory);
+static SkTRegistry<SkBenchmark*, void*> gPolygonReg(PolygonFactory);
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index 00dfb8425b..87bf67ae8b 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -41,31 +41,5 @@ static inline SkIPoint SkMakeIPoint(int x, int y) {
return p;
}
-///////////////////////////////////////////////////////////////////////////////
-
-template <typename T> class SkTRegistry : SkNoncopyable {
-public:
- typedef T* (*Factory)();
-
- SkTRegistry(Factory fact) {
- fFact = fact;
- fChain = gHead;
- gHead = this;
- }
-
- static const SkTRegistry* Head() { return gHead; }
-
- SkTRegistry* next() const { return fChain; }
- Factory factory() const { return fFact; }
-
-private:
- Factory fFact;
- SkTRegistry* fChain;
-
- static SkTRegistry* gHead;
-};
-
-template <typename T> SkTRegistry<T>* SkTRegistry<T>::gHead;
-
#endif
diff --git a/bench/main.cpp b/bench/main.cpp
index d9bd5774c5..25ab73a079 100644
--- a/bench/main.cpp
+++ b/bench/main.cpp
@@ -1,13 +1,12 @@
-#define SAVE_FILE
-
#include "SkCanvas.h"
#include "SkImageEncoder.h"
#include "SkString.h"
#include "SkTime.h"
+#include "SkTRegistry.h"
#include "SkBenchmark.h"
-typedef SkTRegistry<SkBenchmark> BenchRegistry;
+typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry;
class Iter {
public:
@@ -19,7 +18,7 @@ public:
if (fBench) {
BenchRegistry::Factory f = fBench->factory();
fBench = fBench->next();
- return f();
+ return f(0);
}
return NULL;
}
@@ -46,7 +45,6 @@ static void make_filename(const char name[], SkString* path) {
static void saveFile(const char name[], const char config[], const char dir[],
const SkBitmap& bm) {
-#ifdef SAVE_FILE
SkBitmap copy;
if (!bm.copyTo(&copy, SkBitmap::kARGB_8888_Config)) {
return;
@@ -59,7 +57,6 @@ static void saveFile(const char name[], const char config[], const char dir[],
::remove(str.c_str());
SkImageEncoder::EncodeFile(str.c_str(), copy, SkImageEncoder::kPNG_Type,
100);
-#endif
}
static void performClip(SkCanvas* canvas, int w, int h) {