Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: bench/BigPathBench.cpp

Issue 909563002: add bench for very big paths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move giant path data into sep file Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | bench/BigPathBench.inc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/BigPathBench.cpp
diff --git a/bench/BigPathBench.cpp b/bench/BigPathBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a8d7f8fe28dd7896d97ed940e792e73be82699ae
--- /dev/null
+++ b/bench/BigPathBench.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Benchmark.h"
+#include "SkCanvas.h"
+#include "SkPath.h"
+#include "SkString.h"
+
+static void make_path(SkPath& path) {
+ #include "BigPathBench.inc"
+}
+
+enum Align {
+ kLeft_Align,
+ kMiddle_Align,
+ kRight_Align
+};
+
+const char* gAlignName[] = { "left", "middle", "right" };
+
+// Inspired by crbug.com/455429
+class BigPathBench : public Benchmark {
+ SkPath fPath;
+ SkString fName;
+ Align fAlign;
+
+public:
+ BigPathBench(Align align) : fAlign(align) {
+ fName.printf("bigpath_%s", gAlignName[fAlign]);
+ }
+
+protected:
+ const char* onGetName() SK_OVERRIDE {
+ return fName.c_str();
+ }
+
+ SkIPoint onGetSize() SK_OVERRIDE {
+ return SkIPoint::Make(640, 100);
+ }
+
+ void onPreDraw() SK_OVERRIDE {
+ make_path(fPath);
+ }
+
+ void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(2);
+ this->setupPaint(&paint);
+
+ const SkRect r = fPath.getBounds();
+ switch (fAlign) {
+ case kLeft_Align:
+ canvas->translate(-r.left(), 0);
+ break;
+ case kMiddle_Align:
+ break;
+ case kRight_Align:
+ canvas->translate(640 - r.right(), 0);
+ break;
+ }
+
+ for (int i = 0; i < loops; i++) {
+ canvas->drawPath(fPath, paint);
+ }
+ }
+
+private:
+ typedef Benchmark INHERITED;
+};
+
+DEF_BENCH( return new BigPathBench(kLeft_Align); )
+DEF_BENCH( return new BigPathBench(kMiddle_Align); )
+DEF_BENCH( return new BigPathBench(kRight_Align); )
+
« no previous file with comments | « no previous file | bench/BigPathBench.inc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698