7571f9e490
Mechanically updated via Xcode "Replace Regular Expression": typedef (.*) INHERITED; --> using INHERITED = $1; The ClangTidy approach generated an even larger CL which would have required a significant amount of hand-tweaking to be usable. Change-Id: I671dc9d9efdf6d60151325c8d4d13fad7e10a15b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314999 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
81 lines
2.3 KiB
C++
81 lines
2.3 KiB
C++
/*
|
|
* Copyright 2014 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "bench/Benchmark.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkMaskFilter.h"
|
|
#include "include/core/SkPaint.h"
|
|
#include "include/core/SkPath.h"
|
|
#include "include/core/SkRect.h"
|
|
#include "include/core/SkString.h"
|
|
|
|
class BlurRectsBench : public Benchmark {
|
|
public:
|
|
BlurRectsBench(SkRect outer, SkRect inner, SkScalar radius) {
|
|
fRadius = radius;
|
|
fOuter = outer;
|
|
fInner = inner;
|
|
}
|
|
|
|
const char* onGetName() override {
|
|
return fName.c_str();
|
|
}
|
|
|
|
void setName(const SkString& name) {
|
|
fName = name;
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas* canvas) override {
|
|
SkPaint paint;
|
|
paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, fRadius));
|
|
|
|
SkPath path;
|
|
path.addRect(fOuter, SkPathDirection::kCW);
|
|
path.addRect(fInner, SkPathDirection::kCW);
|
|
|
|
for (int i = 0; i < loops; i++) {
|
|
canvas->drawPath(path, paint);
|
|
}
|
|
}
|
|
|
|
private:
|
|
SkString fName;
|
|
SkRect fOuter;
|
|
SkRect fInner;
|
|
SkScalar fRadius;
|
|
|
|
using INHERITED = Benchmark;
|
|
};
|
|
|
|
class BlurRectsNinePatchBench: public BlurRectsBench {
|
|
public:
|
|
BlurRectsNinePatchBench(SkRect outer, SkRect inner, SkScalar radius)
|
|
: INHERITED(outer, inner, radius) {
|
|
this->setName(SkString("blurrectsninepatch"));
|
|
}
|
|
private:
|
|
using INHERITED = BlurRectsBench;
|
|
};
|
|
|
|
class BlurRectsNonNinePatchBench: public BlurRectsBench {
|
|
public:
|
|
BlurRectsNonNinePatchBench(SkRect outer, SkRect inner, SkScalar radius)
|
|
: INHERITED(outer, inner, radius) {
|
|
SkString name;
|
|
this->setName(SkString("blurrectsnonninepatch"));
|
|
}
|
|
private:
|
|
using INHERITED = BlurRectsBench;
|
|
};
|
|
|
|
DEF_BENCH(return new BlurRectsNinePatchBench(SkRect::MakeXYWH(10, 10, 100, 100),
|
|
SkRect::MakeXYWH(20, 20, 60, 60),
|
|
2.3f);)
|
|
DEF_BENCH(return new BlurRectsNonNinePatchBench(SkRect::MakeXYWH(10, 10, 100, 100),
|
|
SkRect::MakeXYWH(50, 50, 10, 10),
|
|
4.3f);)
|