Add a benchmark of filterColor4f with the matrix color filter

Bug: skia:11730
Change-Id: Icbb1f6acf31e3f130cb48338a1c44ca14f40e587
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/383697
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
Brian Osman 2021-03-11 10:32:55 -05:00 committed by Skia Commit-Bot
parent edff467fd4
commit 3527389e28

View File

@ -217,3 +217,35 @@ DEF_BENCH( return new ColorFilterBench("matrix_runtime", []() {
&input, 1);
});)
#endif
class FilterColorBench final : public Benchmark {
public:
explicit FilterColorBench() {}
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
private:
const char* onGetName() override { return "matrix_filterColor4f"; }
void onDelayedSetup() override {
SkScalar colorMatrix[20] = {
0.9f, 0.9f, 0.9f, 0.9f, 0.9f,
0.9f, 0.9f, 0.9f, 0.9f, 0.9f,
0.9f, 0.9f, 0.9f, 0.9f, 0.9f,
0.9f, 0.9f, 0.9f, 0.9f, 0.9f
};
fColorFilter = SkColorFilters::Matrix(colorMatrix);
}
void onDraw(int loops, SkCanvas*) override {
SkColor4f c = { 1.f, 1.f, 0.f, 1.0f };
for (int i = 0; i < loops; ++i) {
c = fColorFilter->filterColor4f(c, /*srcCS=*/nullptr, /*dstCS=*/nullptr);
}
}
sk_sp<SkColorFilter> fColorFilter;
};
DEF_BENCH( return new FilterColorBench(); )