16#if defined(SK_ENABLE_SVG)
23 "svg or skp for the IntersectionTree bench to sniff paths from.");
50 for (
int i = 0; i < loops; ++i) {
60 while (rectCount > 0) {
62 int collidedCount = 0;
63 for (
int i = 0; i < rectCount; ++i) {
64 if (!intersectionTree.
add(rects[i])) {
65 collided[collidedCount++] = rects[i];
68 std::swap(rects, collided);
72 rectCount = collidedCount;
89 fName.
printf(
"IntersectionTree_%i", numRandomRects);
95 for (
int i = 0; i < fNumRandomRects; ++i) {
103 const int fNumRandomRects;
109 if (FLAGS_intersectionTreeFile.isEmpty()) {
112 const char* filename = strrchr(FLAGS_intersectionTreeFile[0],
'/');
116 filename = FLAGS_intersectionTreeFile[0];
118 fName.
printf(
"IntersectionTree_file_%s", filename);
123 if (FLAGS_intersectionTreeFile.isEmpty()) {
130 if (FLAGS_intersectionTreeFile.isEmpty()) {
139 if (path.isConvex()) {
142 int numVerbs = path.countVerbs();
143 SkRect drawBounds = matrix.mapRect(path.getBounds());
144 float gpuFragmentWork = drawBounds.
height() * drawBounds.
width();
145 float cpuTessellationWork = numVerbs *
SkNextLog2(numVerbs);
146 constexpr static float kCpuWeight = 512;
147 constexpr static float kMinNumPixelsToTriangulate = 256 * 256;
148 if (cpuTessellationWork * kCpuWeight + kMinNumPixelsToTriangulate < gpuFragmentWork) {
153 const char* path = FLAGS_intersectionTreeFile[0];
154 if (
const char* ext = strrchr(path,
'.'); ext && !strcmp(ext,
".svg")) {
155#if defined(SK_ENABLE_SVG)
158 SK_ABORT(
"must compile with svg backend to process svgs");
163 SkDebugf(
">> Found %i stencil/cover paths in %s <<\n",
164 rects->
size(), FLAGS_intersectionTreeFile[0]);
168 if (FLAGS_intersectionTreeFile.isEmpty()) {
171 SkDebugf(
">> Reordered %s into %i different stencil/cover draws <<\n",
172 FLAGS_intersectionTreeFile[0],
fNumTrees);
#define DEFINE_string(name, defaultValue, helpString)
#define SK_ABORT(message,...)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static int SkNextLog2(uint32_t value)
T * makeArray(size_t count)
@ kStroke_Style
set to stroke geometry
float nextRangeF(float min, float max)
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
void gatherRects(TArray< SkRect > *rects) override
bool isSuitableFor(Backend backend) final
void onPerCanvasPostDraw(SkCanvas *) override
const char * onGetName() final
bool isSuitableFor(Backend backend) override
void onDraw(int loops, SkCanvas *) final
virtual void gatherRects(TArray< SkRect > *rects)=0
void onDelayedSetup() final
SkArenaAlloc fAlignedAllocator
void gatherRects(TArray< SkRect > *rects) override
RandomIntersectionBench(int numRandomRects)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
constexpr float height() const
constexpr float width() const