Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FindCubicConvex180ChopsBench.cpp
Go to the documentation of this file.
1/*
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"
10
12public:
13 FindCubicConvex180ChopsBench(const std::array<SkPoint,4>& pts, const char* suffix) : fPts(pts) {
14 fName.printf("FindCubicConvex180Chops%s", suffix);
15 }
16
17private:
18 const char* onGetName() override { return fName.c_str(); }
19 bool isSuitableFor(Backend backend) final { return backend == Backend::kNonRendering; }
20 void onDraw(int loops, SkCanvas*) final {
21 float T[2] = {0};
22 bool areCusps;
23 int iters = 50000 * loops;
24 for (int i = 0; i < iters; ++i) {
25 int count = skgpu::tess::FindCubicConvex180Chops(fPts.data(), T, &areCusps);
26 if (T[0] == 200.7f) {
27 // This will never happen. Pretend to use the result to keep the compiler honest.
28 SkDebugf("%i%f%f", count, T[0], T[1]);
29 }
30 }
31 }
32
33 SkString fName;
34 std::array<SkPoint,4> fPts;
35};
36
37DEF_BENCH(return new FindCubicConvex180ChopsBench({{{0,0}, {100,0}, {50,100}, {100,100}}},
38 "_inflect1");)
39DEF_BENCH(return new FindCubicConvex180ChopsBench({{{0,0}, {50,0}, {100,50}, {100,100}}},
40 "_loop");)
#define DEF_BENCH(code)
Definition Benchmark.h:20
const char * backend
int count
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
bool isSuitableFor(Backend backend) final
FindCubicConvex180ChopsBench(const std::array< SkPoint, 4 > &pts, const char *suffix)
void onDraw(int loops, SkCanvas *) final
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:534
const char * c_str() const
Definition SkString.h:133
int FindCubicConvex180Chops(const SkPoint pts[], float T[2], bool *areCusps)
#define T