48 float x = std::ldexp(rand.
nextF(), (i % maxPow2)) / 1e3f;
49 path.cubicTo(111.625f*
x, 308.188f*
x, 764.62f*
x, -435.688f*
x, 742.63f*
x, 85.187f*
x);
50 path.cubicTo(764.62f*
x, -435.688f*
x, 111.625f*
x, 308.188f*
x, 0, 0);
59 for (
int j = -10; j <= 10; j++) {
60 const float x = std::ldexp(rand.
nextF(), (i % 18)) / 1e3f;
61 const float w = std::ldexp(1 + rand.
nextF(), j);
62 path.conicTo(111.625f *
x, 308.188f *
x, 764.62f *
x, -435.688f *
x,
w);
72 float x = std::ldexp(rand.
nextF(), (i % maxPow2)) / 1e3f;
73 path.quadTo(111.625f *
x, 308.188f *
x, 764.62f *
x, -435.688f *
x);
82 float x = std::ldexp(rand.
nextF(), (i % maxPow2)) / 1e3f;
83 path.lineTo(764.62f *
x, -435.688f *
x);
106 SkDebugf(
"ERROR: could not create mock context.");
109 for (
int i = 0; i < loops; ++i) {
123#define DEF_PATH_TESS_BENCH(NAME, PATH, MATRIX) \
124 class PathTessellateBenchmark_##NAME : public PathTessellateBenchmark { \
126 PathTessellateBenchmark_##NAME() : PathTessellateBenchmark(#NAME, (PATH), (MATRIX)) {} \
127 void runBench() override; \
129 DEF_BENCH( return new PathTessellateBenchmark_##NAME(); ); \
130 void PathTessellateBenchmark_##NAME::runBench()
133 1.0001f, 0.0001f, 0.0001f,
134 -.0001f, 0.9999f, -.0001f,
142 fTarget->caps().shaderCaps()->fInfinitySupport);
143 tess->prepare(fTarget.get(),
145 {gAlmostIdentity, fPath, SK_PMColor4fTRANSPARENT},
154 fTarget->caps().shaderCaps()->fInfinitySupport);
155 tess->prepare(fTarget.get(),
157 {gAlmostIdentity, fPath, SK_PMColor4fTRANSPARENT},
237 for (
auto [p0, p1, p2] : it.nextStack()) {
238 vertexWriter << m.map2Points(p0, p1) << m.mapPoint(p2);
249 path.cubicTo(100, 0, 50, 100, 100, 100);
250 path.cubicTo(0, -100, 200, 100, 0, 0);
260 std::vector<PathStrokeList> pathStrokes;
262 for (
int i = 0; i < 8702; ++i) {
267 for (
int j = 0; j < numVerbs; ++j) {
268 switch (rand.
nextU() & 3) {
276 auto [
x,
y] = (path.isEmpty())
288 float y = (path.isEmpty())
319 : fMakePathStrokesFn(makePathStrokesFn)
320 , fPatchAttribs(attribs)
321 , fMatrixScale(matrixScale) {
322 fName.
printf(
"tessellate_%s", suffix);
331 if (!fTarget->mockContext()) {
332 SkDebugf(
"ERROR: could not create mock context.");
336 fPathStrokes = fMakePathStrokesFn();
337 for (
size_t i = 0; i < fPathStrokes.size(); ++i) {
338 if (i + 1 < fPathStrokes.size()) {
339 fPathStrokes[i].fNext = &fPathStrokes[i + 1];
341 fTotalVerbCount += fPathStrokes[i].fPath.countVerbs();
344 fTessellator = std::make_unique<StrokeTessellator>(fPatchAttribs);
348 for (
int i = 0; i < loops; ++i) {
349 fTessellator->prepare(fTarget.get(),
353 fTarget->resetAllocator();
361 std::unique_ptr<GrMockOpTarget> fTarget;
362 std::vector<PathStrokeList> fPathStrokes;
363 std::unique_ptr<StrokeTessellator> fTessellator;
365 int fTotalVerbCount = 0;
370 "GrStrokeFixedCountTessellator");
375 "GrStrokeFixedCountTessellator_one_chop");
380 "GrStrokeFixedCountTessellator_motionmark");
static const int strokeWidth
#define SK_ABORT(message,...)
@ kSrcOver
r = s + (1-sa)*d
constexpr SkPMColor4f SK_PMColor4fWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static int SkNextLog2(uint32_t value)
@ kCubic
SkPath::RawIter returns 4 points.
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
#define DEF_PATH_TESS_BENCH(NAME, PATH, MATRIX)
Type::kYUV Type::kRGBA() int(0.7 *637)
static sk_sp< GrDirectContext > MakeMock(const GrMockOptions *, const GrContextOptions &)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
static const SkMatrix & I()
@ kButt_Cap
no stroke extension
@ kMiter_Join
extends to miter limit
@ kBevel_Join
connects outside edges
static const SkPoint * PointData(const SkPath &path)
SkPath & moveTo(SkScalar x, SkScalar y)
uint32_t nextULessThan(uint32_t count)
float nextRangeF(float min, float max)
uint32_t nextRangeU(uint32_t min, uint32_t max)
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
void setStrokeStyle(SkScalar width, bool strokeAndFill=false)
void setStrokeParams(SkPaint::Cap cap, SkPaint::Join join, SkScalar miterLimit)
static constexpr Swizzle RGBA()
static PathCurveTessellator * Make(SkArenaAlloc *arena, bool infinitySupport, PatchAttribs attribs=PatchAttribs::kNone)
PathTessellateBenchmark(const char *subName, const SkPath &p, const SkMatrix &m)
const char * onGetName() override
virtual void runBench()=0
void onDraw(int loops, SkCanvas *) final
std::unique_ptr< GrMockOpTarget > fTarget
bool isSuitableFor(Backend backend) final
void onDelayedSetup() override
static PathWedgeTessellator * Make(SkArenaAlloc *arena, bool infinitySupport, PatchAttribs attribs=PatchAttribs::kNone)
const char * onGetName() override
void onDraw(int loops, SkCanvas *) final
void onDelayedSetup() override
bool isSuitableFor(Backend backend) final
TessPrepareBench(MakePathStrokesFn makePathStrokesFn, PatchAttribs attribs, float matrixScale, const char *suffix)
static const uint8_t buffer[]
static SkPath make_line_path(int maxPow2)
static void benchmark_wangs_formula_conic_log2(const SkMatrix &matrix, const SkPath &path)
static SkPath make_cubic_path(int maxPow2)
static constexpr int kNumCubicsInChalkboard
static SkPath make_quad_path(int maxPow2)
static std::vector< PathStrokeList > make_simple_cubic_path()
static void benchmark_wangs_formula_cubic_log2(const SkMatrix &matrix, const SkPath &path)
std::vector< PathStrokeList >(*)() MakePathStrokesFn
static sk_sp< GrDirectContext > make_mock_context()
static const SkMatrix gAlmostIdentity
static void benchmark_wangs_formula_conic(const SkMatrix &matrix, const SkPath &path)
static SkPath make_conic_path()
static std::vector< PathStrokeList > make_motionmark_paths()
bool fDrawInstancedSupport
ConfigOptions fConfigOptions[kGrColorTypeCnt]
static constexpr SkRect MakeWH(float w, float h)