Update blendmode benchmark to allow less than 1000 iterations.

On Mali 400 devices, 1000 iterations is way too many, causing this
benchmark to take five seconds per variation:
http://screen/5AdKPZynP7myjfR

This change should help lighten the load on the tree for older devices.

Change-Id: I3f719093c3f7fdbc81ab41c29ce6d93f36360b7b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388444
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-03-24 10:06:41 -04:00 committed by Skia Commit-Bot
parent 9e13fe86b1
commit 06b6f47950

View File

@ -19,7 +19,7 @@ class XfermodeBench : public Benchmark {
public:
XfermodeBench(SkBlendMode mode, bool aa) : fBlendMode(mode) {
fAA = aa;
fName.printf("blendmode_%s_%s", aa ? "mask" : "rect", SkBlendMode_Name(mode));
fName.printf("blendmicro_%s_%s", aa ? "mask" : "rect", SkBlendMode_Name(mode));
}
protected:
@ -30,7 +30,7 @@ protected:
size_t len = strlen(text);
SkISize size = canvas->getBaseLayerSize();
SkRandom random;
for (int i = 0; i < loops; ++i) {
while (loops > 0) {
SkPaint paint;
paint.setBlendMode(fBlendMode);
paint.setColor(random.nextU());
@ -41,9 +41,11 @@ protected:
SkScalar x = random.nextRangeScalar(0, (SkScalar)size.fWidth),
y = random.nextRangeScalar(0, (SkScalar)size.fHeight);
auto blob = SkTextBlob::MakeFromText(text, len, font, SkTextEncoding::kUTF8);
for (int j = 0; j < 1000; ++j) {
int iterations = std::min(1000, loops);
for (int j = 0; j < iterations; ++j) {
canvas->drawTextBlob(blob, x, y, paint);
}
loops -= iterations;
} else {
// Draw rects to exercise non-AA code paths.
SkScalar w = random.nextRangeScalar(50, 100);
@ -54,9 +56,11 @@ protected:
w,
h
);
for (int j = 0; j < 1000; ++j) {
int iterations = std::min(1000, loops);
for (int j = 0; j < iterations; ++j) {
canvas->drawRect(rect, paint);
}
loops -= iterations;
}
}
}