add bench for patchutils
Bug: skia:
Change-Id: Iba36eb5a7d09f92b7828f2ec209cbfeb8d0eb8ed
Reviewed-on: https://skia-review.googlesource.com/17601
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/bench/PatchBench.cpp b/bench/PatchBench.cpp
index d1d253b..4ca4bc8 100644
--- a/bench/PatchBench.cpp
+++ b/bench/PatchBench.cpp
@@ -322,3 +322,34 @@
PatchBench::kTexCoords_VertexMode); )
DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f),
PatchBench::kBoth_VertexMode); )
+
+//////////////////////////////////////////////
+#include "SkPatchUtils.h"
+
+class PatchUtilsBench : public Benchmark {
+public:
+ const char* onGetName() override {
+ return "patchutils";
+ }
+
+ bool isSuitableFor(Backend backend) override {
+ return backend == kNonRendering_Backend;
+ }
+
+ void onDraw(int, SkCanvas*) override {
+ const SkColor colors[] = { 0xFF000000, 0xFF00FF00, 0xFF0000FF, 0xFFFF0000 };
+ const SkPoint pts[] = {
+ { 0, 0 }, { 10, 0 }, { 20, 0 }, { 30, 0 },
+ { 30,10}, { 30,20 }, { 30,30 }, { 20,30 },
+ { 10,30}, { 0, 30 }, { 0, 20 }, { 0, 10 },
+ };
+ const SkPoint tex[] = {
+ { 0, 0 }, { 10, 0 }, { 10, 10 }, { 0, 10 },
+ };
+
+ for (int i = 0; i < 100; ++i) {
+ SkPatchUtils::MakeVertices(pts, colors, tex, 20, 20);
+ }
+ }
+};
+DEF_BENCH( return new PatchUtilsBench; )