2882e70ef3
This method finds the locations a cubic needs to be chopped at before it can be passed to the stroke tessellation shader. It's an integral part of CPU stroke preparation and therefore extremely perf sensitive. Bug: skia:10419 Change-Id: Ib23c2583b8cfc78814ce52425f7af2c8b2f8b420 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330314 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
38 lines
1.3 KiB
C++
38 lines
1.3 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/geometry/GrPathUtils.h"
|
|
|
|
class FindCubicConvex180Chops : public Benchmark {
|
|
public:
|
|
FindCubicConvex180Chops(const std::array<SkPoint,4>& pts, const char* suffix) : fPts(pts) {
|
|
fName.printf("GrPathUtils_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};
|
|
int iters = 50000 * loops;
|
|
for (int i = 0; i < iters; ++i) {
|
|
int count = GrPathUtils::findCubicConvex180Chops(fPts.data(), T);
|
|
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 FindCubicConvex180Chops({{{0,0}, {100,0}, {50,100}, {100,100}}}, "_inflect1");)
|
|
DEF_BENCH(return new FindCubicConvex180Chops({{{0,0}, {50,0}, {100,50}, {100,100}}}, "_loop");)
|