aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar anatoly@google.com <anatoly@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-04-12 13:51:28 +0000
committerGravatar anatoly@google.com <anatoly@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-04-12 13:51:28 +0000
commita956e4fe2e7a6701f778c632ff11e8a0ed01168f (patch)
treedc730414d788edc6ad7faa654ef25b8d68981a28 /bench
parent229d9b3953a84365e0cf4848556c0795af4446da (diff)
Use hairline when line width <= 1.0, instead of < 1.0.
This speeds line drawing up considerably when drawing with default linewidth on canvas. Review: http://codereview.appspot.com/883047/show git-svn-id: http://skia.googlecode.com/svn/trunk@538 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r--bench/RectBench.cpp13
-rw-r--r--bench/SkBenchmark.cpp1
-rw-r--r--bench/SkBenchmark.h16
-rw-r--r--bench/benchmain.cpp18
4 files changed, 43 insertions, 5 deletions
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp
index 6f34eb5638..3874bb3fc7 100644
--- a/bench/RectBench.cpp
+++ b/bench/RectBench.cpp
@@ -89,14 +89,20 @@ public:
protected:
virtual void onDraw(SkCanvas* canvas) {
- static const SkScalar gSizes[] = {
+ SkScalar gSizes[] = {
SkIntToScalar(7), 0
};
+ size_t sizes = SK_ARRAY_COUNT(gSizes);
+
+ if (this->hasStrokeWidth()) {
+ gSizes[0] = this->getStrokeWidth();
+ sizes = 1;
+ }
SkPaint paint;
paint.setStrokeCap(SkPaint::kRound_Cap);
-
- for (size_t i = 0; i < SK_ARRAY_COUNT(gSizes); i++) {
+
+ for (size_t i = 0; i < sizes; i++) {
paint.setStrokeWidth(gSizes[i]);
this->setupPaint(&paint);
canvas->drawPoints(fMode, N * 2,
@@ -132,4 +138,3 @@ static BenchRegistry gRRectReg2(RRectFactory2);
static BenchRegistry gPointsReg(PointsFactory);
static BenchRegistry gLinesReg(LinesFactory);
static BenchRegistry gPolygonReg(PolygonFactory);
-
diff --git a/bench/SkBenchmark.cpp b/bench/SkBenchmark.cpp
index e8bea6e255..230a7afd9c 100644
--- a/bench/SkBenchmark.cpp
+++ b/bench/SkBenchmark.cpp
@@ -9,6 +9,7 @@ SkBenchmark::SkBenchmark(void* defineDict) {
fForceAlpha = 0xFF;
fForceAA = true;
fDither = SkTriState::kDefault;
+ fHasStrokeWidth = false;
}
const char* SkBenchmark::getName() {
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index bc9794a34d..945db8082f 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -42,6 +42,19 @@ public:
fDither = state;
}
+ void setStrokeWidth(SkScalar width) {
+ strokeWidth = width;
+ fHasStrokeWidth = true;
+ }
+
+ SkScalar getStrokeWidth() {
+ return strokeWidth;
+ }
+
+ bool hasStrokeWidth() {
+ return fHasStrokeWidth;
+ }
+
const char* findDefine(const char* key) const;
bool findDefine32(const char* key, int32_t* value) const;
bool findDefineScalar(const char* key, SkScalar* value) const;
@@ -60,9 +73,10 @@ private:
bool fForceAA;
bool fForceFilter;
SkTriState::State fDither;
+ bool fHasStrokeWidth;
+ SkScalar strokeWidth;
};
typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry;
#endif
-
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 7443604dae..2f8b006fda 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -201,6 +201,8 @@ int main (int argc, char * const argv[]) {
bool doClip = false;
bool doPict = false;
const char* matchStr = NULL;
+ bool hasStrokeWidth = false;
+ float strokeWidth;
SkString outDir;
SkBitmap::Config outConfig = SkBitmap::kNo_Config;
@@ -260,6 +262,19 @@ int main (int argc, char * const argv[]) {
return -1;
}
forceAlpha = wantAlpha ? 0x80 : 0xFF;
+ } else if (strcmp(*argv, "-strokeWidth") == 0) {
+ argv++;
+ if (argv < stop) {
+ const char *strokeWidthStr = *argv;
+ if (sscanf(strokeWidthStr, "%f", &strokeWidth) != 1) {
+ log_error("bad arg for -strokeWidth\n");
+ return -1;
+ }
+ hasStrokeWidth = true;
+ } else {
+ log_error("missing arg for -strokeWidth\n");
+ return -1;
+ }
} else if (strcmp(*argv, "-match") == 0) {
argv++;
if (argv < stop) {
@@ -314,6 +329,9 @@ int main (int argc, char * const argv[]) {
bench->setForceAA(forceAA);
bench->setForceFilter(forceFilter);
bench->setDither(forceDither);
+ if (hasStrokeWidth) {
+ bench->setStrokeWidth(strokeWidth);
+ }
// only run benchmarks if their name contains matchStr
if (matchStr && strstr(bench->getName(), matchStr) == NULL) {