blob: 1d02f5c88bfe1dc75bd3f1b8ed0ea8219c35e2f7 [file] [log] [blame]
Chris Dalton2882e702020-11-02 12:43:06 -07001/*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "bench/Benchmark.h"
9#include "src/gpu/geometry/GrPathUtils.h"
10
11class FindCubicConvex180Chops : public Benchmark {
12public:
13 FindCubicConvex180Chops(const std::array<SkPoint,4>& pts, const char* suffix) : fPts(pts) {
14 fName.printf("GrPathUtils_findCubicConvex180Chops%s", suffix);
15 }
16
17private:
18 const char* onGetName() override { return fName.c_str(); }
19 bool isSuitableFor(Backend backend) final { return backend == kNonRendering_Backend; }
20 void onDraw(int loops, SkCanvas*) final {
21 float T[2] = {0};
22 int iters = 50000 * loops;
23 for (int i = 0; i < iters; ++i) {
24 int count = GrPathUtils::findCubicConvex180Chops(fPts.data(), T);
25 if (T[0] == 200.7f) {
26 // This will never happen. Pretend to use the result to keep the compiler honest.
27 SkDebugf("%i%f%f", count, T[0], T[1]);
28 }
29 }
30 }
31
32 SkString fName;
33 std::array<SkPoint,4> fPts;
34};
35
36DEF_BENCH(return new FindCubicConvex180Chops({{{0,0}, {100,0}, {50,100}, {100,100}}}, "_inflect1");)
37DEF_BENCH(return new FindCubicConvex180Chops({{{0,0}, {50,0}, {100,50}, {100,100}}}, "_loop");)