New benchmark to create many random quadratic paths.

Added to try to get a handle on the cost of CPU-side changes to GPU rendering, but probably too noisy to be useful.



git-svn-id: http://skia.googlecode.com/svn/trunk@1674 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
tomhudson@google.com 2011-06-22 17:16:35 +00:00
Родитель d3aed39ab1
Коммит 6e8d335b45
1 изменённых файлов: 41 добавлений и 5 удалений

Просмотреть файл

@ -3,6 +3,7 @@
#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkPaint.h"
#include "SkRandom.h"
#include "SkShader.h"
#include "SkString.h"
@ -31,7 +32,7 @@ public:
virtual void appendName(SkString*) = 0;
virtual void makePath(SkPath*) = 0;
virtual bool iscomplex() { return false; }
virtual int complexity() { return 0; }
protected:
virtual const char* onGetName() {
@ -58,9 +59,7 @@ protected:
if (fFlags & kBig_Flag) {
count >>= 2;
}
if (this->iscomplex()) {
count >>= 3;
}
count >>= (3 * complexity());
for (int i = 0; i < count; i++) {
canvas->drawPath(path, paint);
@ -146,11 +145,38 @@ public:
path->lineTo(x0, y + 2 * dy);
path->close();
}
virtual bool iscomplex() { return true; }
virtual int complexity() { return 1; }
private:
typedef PathBench INHERITED;
};
class LongCurvedPathBench : public PathBench {
public:
LongCurvedPathBench(void * param, Flags flags)
: INHERITED(param, flags) {
}
virtual void appendName(SkString* name) {
name->append("long_curved");
}
virtual void makePath(SkPath* path) {
SkRandom rand (12);
int i;
for (i = 0; i < 100; i++) {
path->quadTo(SkScalarMul(rand.nextUScalar1(), SkIntToScalar(640)),
SkScalarMul(rand.nextUScalar1(), SkIntToScalar(480)),
SkScalarMul(rand.nextUScalar1(), SkIntToScalar(640)),
SkScalarMul(rand.nextUScalar1(), SkIntToScalar(480)));
}
path->close();
}
virtual int complexity() { return 2; }
private:
typedef PathBench INHERITED;
};
static SkBenchmark* FactT00(void* p) { return new TrianglePathBench(p, FLAGS00); }
static SkBenchmark* FactT01(void* p) { return new TrianglePathBench(p, FLAGS01); }
static SkBenchmark* FactT10(void* p) { return new TrianglePathBench(p, FLAGS10); }
@ -169,6 +195,13 @@ static SkBenchmark* FactO11(void* p) { return new OvalPathBench(p, FLAGS11); }
static SkBenchmark* FactS00(void* p) { return new SawToothPathBench(p, FLAGS00); }
static SkBenchmark* FactS01(void* p) { return new SawToothPathBench(p, FLAGS01); }
static SkBenchmark* FactLC00(void* p) {
return new LongCurvedPathBench(p, FLAGS00);
}
static SkBenchmark* FactLC01(void* p) {
return new LongCurvedPathBench(p, FLAGS01);
}
static BenchRegistry gRegT00(FactT00);
static BenchRegistry gRegT01(FactT01);
static BenchRegistry gRegT10(FactT10);
@ -187,3 +220,6 @@ static BenchRegistry gRegO11(FactO11);
static BenchRegistry gRegS00(FactS00);
static BenchRegistry gRegS01(FactS01);
static BenchRegistry gRegLC00(FactLC00);
static BenchRegistry gRegLC01(FactLC01);