diff options
-rw-r--r-- | bench/SkBenchmark.cpp | 1 | ||||
-rw-r--r-- | bench/SkBenchmark.h | 7 | ||||
-rw-r--r-- | bench/benchmain.cpp | 72 | ||||
-rw-r--r-- | include/utils/SkNWayCanvas.h (renamed from include/effects/SkNWayCanvas.h) | 0 | ||||
-rw-r--r-- | src/utils/SkNWayCanvas.cpp (renamed from src/effects/SkNWayCanvas.cpp) | 0 |
5 files changed, 64 insertions, 16 deletions
diff --git a/bench/SkBenchmark.cpp b/bench/SkBenchmark.cpp index 853afb3e91..7bc87ee82b 100644 --- a/bench/SkBenchmark.cpp +++ b/bench/SkBenchmark.cpp @@ -23,6 +23,7 @@ void SkBenchmark::draw(SkCanvas* canvas) { void SkBenchmark::setupPaint(SkPaint* paint) { paint->setAlpha(fForceAlpha); paint->setAntiAlias(fForceAA); + paint->setFilterBitmap(fForceFilter); } /////////////////////////////////////////////////////////////////////////////// diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h index 27009d9e7d..20582514e0 100644 --- a/bench/SkBenchmark.h +++ b/bench/SkBenchmark.h @@ -23,7 +23,11 @@ public: void setForceAA(bool aa) { fForceAA = aa; } - + + void setForceFilter(bool filter) { + fForceFilter = filter; + } + protected: void setupPaint(SkPaint* paint); @@ -35,6 +39,7 @@ protected: private: int fForceAlpha; bool fForceAA; + bool fForceFilter; }; static inline SkIPoint SkMakeIPoint(int x, int y) { diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp index 1977a7f84d..501e86aaa4 100644 --- a/bench/benchmain.cpp +++ b/bench/benchmain.cpp @@ -9,6 +9,19 @@ #include "SkBenchmark.h" +#ifdef ANDROID +static void log_error(const char msg[]) { SkDebugf("%s", msg); } +static void log_progress(const char msg[]) { SkDebugf("%s", msg); } +#else +static void log_error(const char msg[]) { fprintf(stderr, "%s", msg); } +static void log_progress(const char msg[]) { printf("%s", msg); } +#endif + +static void log_error(const SkString& str) { log_error(str.c_str()); } +static void log_progress(const SkString& str) { log_progress(str.c_str()); } + +/////////////////////////////////////////////////////////////////////////////// + static void erase(SkBitmap& bm) { if (bm.config() == SkBitmap::kA8_Config) { bm.eraseColor(0); @@ -143,6 +156,14 @@ static void compare_pict_to_bitmap(SkPicture* pict, const SkBitmap& bm) { } } +static bool parse_bool_arg(char * const* argv, char* const* stop, bool* var) { + if (argv < stop) { + *var = atoi(*argv) != 0; + return true; + } + return false; +} + static const struct { SkBitmap::Config fConfig; const char* fName; @@ -168,6 +189,7 @@ int main (int argc, char * const argv[]) { int repeatDraw = 1; int forceAlpha = 0xFF; bool forceAA = true; + bool forceFilter = false; bool doScale = false; bool doRotate = false; bool doClip = false; @@ -199,7 +221,7 @@ int main (int argc, char * const argv[]) { repeatDraw = 1; } } else { - fprintf(stderr, "missing arg for -repeat\n"); + log_error("missing arg for -repeat\n"); return -1; } } else if (!strcmp(*argv, "-rotate")) { @@ -209,19 +231,28 @@ int main (int argc, char * const argv[]) { } else if (!strcmp(*argv, "-clip")) { doClip = true; } else if (strcmp(*argv, "-forceAA") == 0) { - forceAA = true; - } else if (strcmp(*argv, "-forceBW") == 0) { - forceAA = false; + if (!parse_bool_arg(++argv, stop, &forceAA)) { + log_error("missing arg for -forceAA\n"); + return -1; + } + } else if (strcmp(*argv, "-forceFilter") == 0) { + if (!parse_bool_arg(++argv, stop, &forceFilter)) { + log_error("missing arg for -forceFilter\n"); + return -1; + } } else if (strcmp(*argv, "-forceBlend") == 0) { - forceAlpha = 0x80; - } else if (strcmp(*argv, "-forceOpaque") == 0) { - forceAlpha = 0xFF; + bool wantAlpha = false; + if (!parse_bool_arg(++argv, stop, &wantAlpha)) { + log_error("missing arg for -forceBlend\n"); + return -1; + } + forceAlpha = wantAlpha ? 0x80 : 0xFF; } else if (strcmp(*argv, "-match") == 0) { argv++; if (argv < stop) { matchStr = *argv; } else { - fprintf(stderr, "missing arg for -match\n"); + log_error("missing arg for -match\n"); return -1; } } else if (strcmp(*argv, "-config") == 0) { @@ -233,15 +264,19 @@ int main (int argc, char * const argv[]) { configName = gConfigs[index].fName; configCount = 1; } else { - fprintf(stderr, "unrecognized config %s\n", *argv); + SkString str; + str.printf("unrecognized config %s\n", *argv); + log_error(str); return -1; } } else { - fprintf(stderr, "missing arg for -config\n"); + log_error("missing arg for -config\n"); return -1; } } else { - fprintf(stderr, "unrecognized arg %s\n", *argv); + SkString str; + str.printf("unrecognized arg %s\n", *argv); + log_error(str); return -1; } } @@ -256,13 +291,18 @@ int main (int argc, char * const argv[]) { bench->setForceAlpha(forceAlpha); bench->setForceAA(forceAA); + bench->setForceFilter(forceFilter); // only run benchmarks if their name contains matchStr if (matchStr && strstr(bench->getName(), matchStr) == NULL) { continue; } - printf("running bench %16s", bench->getName()); + { + SkString str; + str.printf("running bench %16s", bench->getName()); + log_progress(str); + } for (int configIndex = 0; configIndex < configCount; configIndex++) { if (configCount > 1) { @@ -309,14 +349,16 @@ int main (int argc, char * const argv[]) { } } if (repeatDraw > 1) { - printf(" %4s:%7.2f", configName, - (SkTime::GetMSecs() - now) / (double)repeatDraw); + SkString str; + str.printf(" %4s:%7.2f", configName, + (SkTime::GetMSecs() - now) / (double)repeatDraw); + log_progress(str); } if (outDir.size() > 0) { saveFile(bench->getName(), configName, outDir.c_str(), bm); } } - printf("\n"); + log_progress("\n"); } return 0; diff --git a/include/effects/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h index 03bd6d10c6..03bd6d10c6 100644 --- a/include/effects/SkNWayCanvas.h +++ b/include/utils/SkNWayCanvas.h diff --git a/src/effects/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp index d3c84a145e..d3c84a145e 100644 --- a/src/effects/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp |