add bench for mixers

Bug: skia:
Change-Id: I1b12c0deac802fb9da8bd285c1ff6d7e63da00f3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201687
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2019-03-16 11:46:36 -04:00 committed by Skia Commit-Bot
parent f3f7059cb7
commit 90155edf14
2 changed files with 45 additions and 0 deletions

44
bench/MixerBench.cpp Normal file
View File

@ -0,0 +1,44 @@
/*
* Copyright 2019 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Benchmark.h"
#include "SkCanvas.h"
#include "SkMixer.h"
#include "SkPaint.h"
#include "SkShader.h"
class MixerLerpBench : public Benchmark {
public:
MixerLerpBench() {}
protected:
const char* onGetName() override { return "mixer-lerp"; }
void onDelayedSetup() override {
auto s0 = SkShader::MakeColorShader(SK_ColorRED);
auto s1 = SkShader::MakeColorShader(SK_ColorBLUE);
auto mx = SkMixer::MakeShaderLerp(SkShader::MakeColorShader(0xFF880000));
fShader = SkShader::MakeMixer(s0, s1, mx);
}
void onDraw(int loops, SkCanvas* canvas) override {
const SkRect r = {0, 0, 256, 256};
SkPaint paint;
paint.setShader(fShader);
for (int j = 0; j < 100; ++j) {
for (int i = 0; i < loops; i++) {
canvas->drawRect(r, paint);
}
}
}
private:
sk_sp<SkShader> fShader;
typedef Benchmark INHERITED;
};
DEF_BENCH( return new MixerLerpBench; )

View File

@ -77,6 +77,7 @@ bench_sources = [
"$_bench/MemsetBench.cpp",
"$_bench/MergeBench.cpp",
"$_bench/MipMapBench.cpp",
"$_bench/MixerBench.cpp",
"$_bench/MorphologyBench.cpp",
"$_bench/MutexBench.cpp",
"$_bench/PatchBench.cpp",