skia2/bench/BlurRectsBench.cpp
Mike Reed 0dacc6b7d3 Revert "Use flat version of path-direction enum"
This reverts commit e0fbe94351.

Reason for revert: need to add guard flag to flutter

Original change's description:
> Use flat version of path-direction enum
> 
> Bug: skia:9663
> Change-Id: I00077d9f2b14b3e983e6a46ef6f560cabdb1678d
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242557
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>

TBR=fmalita@chromium.org,reed@google.com

Change-Id: If47173d9b203b2d3a175af290a15d986accb4703
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9663
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255831
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-11-21 22:10:32 +00:00

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, SkPath::kCW_Direction);
path.addRect(fInner, SkPath::kCW_Direction);
for (int i = 0; i < loops; i++) {
canvas->drawPath(path, paint);
}
}
private:
SkString fName;
SkRect fOuter;
SkRect fInner;
SkScalar fRadius;
typedef Benchmark INHERITED;
};
class BlurRectsNinePatchBench: public BlurRectsBench {
public:
BlurRectsNinePatchBench(SkRect outer, SkRect inner, SkScalar radius)
: INHERITED(outer, inner, radius) {
this->setName(SkString("blurrectsninepatch"));
}
private:
typedef BlurRectsBench INHERITED;
};
class BlurRectsNonNinePatchBench: public BlurRectsBench {
public:
BlurRectsNonNinePatchBench(SkRect outer, SkRect inner, SkScalar radius)
: INHERITED(outer, inner, radius) {
SkString name;
this->setName(SkString("blurrectsnonninepatch"));
}
private:
typedef BlurRectsBench INHERITED;
};
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);)