Update benchmarks to use new filter factories
Also refactors 3 duplicate functions that converted an SkTileMode to
a char*. This will rename the matrix convolution benchmarks that used
"clampToBlack" to the more modern "decal" terminology.
Bug: skia:9280
Change-Id: I43a4f9edeba36eb5af1243f7e4ab7647253b91f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230883
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/bench/DisplacementBench.cpp b/bench/DisplacementBench.cpp
index 906a04b..6c9a6bf 100644
--- a/bench/DisplacementBench.cpp
+++ b/bench/DisplacementBench.cpp
@@ -9,8 +9,7 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkFont.h"
#include "include/core/SkSurface.h"
-#include "include/effects/SkDisplacementMapEffect.h"
-#include "include/effects/SkImageSource.h"
+#include "include/effects/SkImageFilters.h"
#define FILTER_WIDTH_SMALL 32
#define FILTER_HEIGHT_SMALL 32
@@ -100,12 +99,10 @@
void onDraw(int loops, SkCanvas* canvas) override {
SkPaint paint;
- sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
+ sk_sp<SkImageFilter> displ(SkImageFilters::Image(fCheckerboard));
// No displacement effect
- paint.setImageFilter(SkDisplacementMapEffect::Make(
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType,
- 0.0f, std::move(displ), nullptr));
+ paint.setImageFilter(SkImageFilters::DisplacementMap(SkColorChannel::kR, SkColorChannel::kG,
+ 0.0f, std::move(displ), nullptr));
for (int i = 0; i < loops; i++) {
this->drawClippedBitmap(canvas, 0, 0, paint);
@@ -127,12 +124,10 @@
void onDraw(int loops, SkCanvas* canvas) override {
SkPaint paint;
- sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
+ sk_sp<SkImageFilter> displ(SkImageFilters::Image(fCheckerboard));
// Displacement, with 1 alpha component (which isn't pre-multiplied)
- paint.setImageFilter(SkDisplacementMapEffect::Make(
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 16.0f, std::move(displ), nullptr));
+ paint.setImageFilter(SkImageFilters::DisplacementMap(SkColorChannel::kB, SkColorChannel::kA,
+ 16.0f, std::move(displ), nullptr));
for (int i = 0; i < loops; i++) {
this->drawClippedBitmap(canvas, 100, 0, paint);
}
@@ -153,12 +148,10 @@
void onDraw(int loops, SkCanvas* canvas) override {
SkPaint paint;
- sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
+ sk_sp<SkImageFilter> displ(SkImageFilters::Image(fCheckerboard));
// Displacement, with 2 non-alpha components
- paint.setImageFilter(SkDisplacementMapEffect::Make(
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- 32.0f, std::move(displ), nullptr));
+ paint.setImageFilter(SkImageFilters::DisplacementMap(SkColorChannel::kR, SkColorChannel::kB,
+ 32.0f, std::move(displ), nullptr));
for (int i = 0; i < loops; ++i) {
this->drawClippedBitmap(canvas, 200, 0, paint);
}