skia2/bench/FindCubicConvex180ChopsBench.cpp
Michael Ludwig 2ad7b3f65e Move src/gpu/tessellate/ types into skgpu::tess namespace
For usages of constants in classes outside of skgpu::tess (e.g. when
using tessellation in skgpu::v1 or skgpu::graphite), the constants are
accessed with tess::. This is just to help with clarity since it scopes
the constant name. However, functions and types are still referred to
without that, and using namespace skgpu::tess is used to keep those
references simpler.

In headers, tess:: is added when there are only a few usages of the
types, or it's brought in as an alias.

Change-Id: I12af595659fe791de419db0393482dae6cd238e3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/534668
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2022-05-06 19:57:42 +00:00

41 lines
1.4 KiB
C++

/*
* Copyright 2020 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "bench/Benchmark.h"
#include "src/gpu/tessellate/Tessellation.h"
class FindCubicConvex180ChopsBench : public Benchmark {
public:
FindCubicConvex180ChopsBench(const std::array<SkPoint,4>& pts, const char* suffix) : fPts(pts) {
fName.printf("FindCubicConvex180Chops%s", suffix);
}
private:
const char* onGetName() override { return fName.c_str(); }
bool isSuitableFor(Backend backend) final { return backend == kNonRendering_Backend; }
void onDraw(int loops, SkCanvas*) final {
float T[2] = {0};
bool areCusps;
int iters = 50000 * loops;
for (int i = 0; i < iters; ++i) {
int count = skgpu::tess::FindCubicConvex180Chops(fPts.data(), T, &areCusps);
if (T[0] == 200.7f) {
// This will never happen. Pretend to use the result to keep the compiler honest.
SkDebugf("%i%f%f", count, T[0], T[1]);
}
}
}
SkString fName;
std::array<SkPoint,4> fPts;
};
DEF_BENCH(return new FindCubicConvex180ChopsBench({{{0,0}, {100,0}, {50,100}, {100,100}}},
"_inflect1");)
DEF_BENCH(return new FindCubicConvex180ChopsBench({{{0,0}, {50,0}, {100,50}, {100,100}}},
"_loop");)