add different stroke-widths to dash bench

git-svn-id: http://skia.googlecode.com/svn/trunk@3843 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
mike@reedtribe.org 2012-05-05 13:46:10 +00:00
parent 35a81dfdb2
commit 99a6ef48e3

View File

@ -29,14 +29,21 @@ static void path_hline(SkPath* path) {
}
class DashBench : public SkBenchmark {
SkString fName;
SkTDArray<SkScalar> fIntervals;
int fWidth;
enum {
N = SkBENCHLOOP(100)
};
public:
DashBench(void* param, const SkScalar intervals[], int count) : INHERITED(param) {
DashBench(void* param, const SkScalar intervals[], int count, int width) : INHERITED(param) {
fIntervals.append(count, intervals);
for (int i = 0; i < count; ++i) {
fIntervals[i] *= width;
}
fWidth = width;
fName.printf("dash_%d", width);
}
virtual void makePath(SkPath* path) {
@ -45,14 +52,14 @@ public:
protected:
virtual const char* onGetName() SK_OVERRIDE {
return "dash";
return fName.c_str();
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
this->setupPaint(&paint);
paint.setStyle(SkPaint::kStroke_Style);
// paint.setStrokeWidth(SK_Scalar1);
paint.setStrokeWidth(SkIntToScalar(fWidth));
paint.setAntiAlias(false);
SkPath path;
@ -75,6 +82,10 @@ static const SkScalar gDots[] = { SK_Scalar1, SK_Scalar1 };
#define PARAM(array) array, SK_ARRAY_COUNT(array)
static SkBenchmark* gF0(void* p) { return new DashBench(p, PARAM(gDots)); }
static SkBenchmark* gF0(void* p) { return new DashBench(p, PARAM(gDots), 0); }
static SkBenchmark* gF1(void* p) { return new DashBench(p, PARAM(gDots), 1); }
static SkBenchmark* gF2(void* p) { return new DashBench(p, PARAM(gDots), 4); }
static BenchRegistry gR0(gF0);
static BenchRegistry gR1(gF1);
static BenchRegistry gR2(gF2);