aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/BlurRoundRectBench.cpp
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-05 21:10:58 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-05 21:10:58 +0000
commit8610d2cdbdcc0e1cf28f9a1ffea0ebab53a33485 (patch)
treeba6f4dbc47a152c1da2804e33a242ea0051fa185 /bench/BlurRoundRectBench.cpp
parent1e698afbc22507438783d36a56428f0b7e715393 (diff)
Fixes for blurroundrect gm/bench.
Simplify naming/various cases. Have an atlas of gms, rather than several different images. In the bench, pull non rendering out of the loop. Use meaningful enums instead of integers where appropriate. Add comments. Addresses comments in https://codereview.chromium.org/52793005/ R=robertphillips@google.com Review URL: https://codereview.chromium.org/59983004 git-svn-id: http://skia.googlecode.com/svn/trunk@12144 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/BlurRoundRectBench.cpp')
-rw-r--r--bench/BlurRoundRectBench.cpp116
1 files changed, 50 insertions, 66 deletions
diff --git a/bench/BlurRoundRectBench.cpp b/bench/BlurRoundRectBench.cpp
index 4fe4902255..c57688a142 100644
--- a/bench/BlurRoundRectBench.cpp
+++ b/bench/BlurRoundRectBench.cpp
@@ -19,30 +19,15 @@
#include "SkString.h"
#include "SkXfermode.h"
+// Large blurred RR appear frequently on web pages. This benchmark measures our
+// performance in this case.
class BlurRoundRectBench : public SkBenchmark {
public:
- BlurRoundRectBench(int width, int height,
- // X and Y radii for the upper left corner
- int ulX, int ulY,
- // X and Y radii for the upper right corner
- int urX, int urY,
- // X and Y radii for the lower right corner
- int lrX, int lrY,
- // X and Y radii for the lower left corner
- int llX, int llY)
- : fName("blurroundrect")
- , fWidth(width)
- , fHeight(height) {
- fName.appendf("_WH[%ix%i]_UL[%ix%i]_UR[%ix%i]_LR[%ix%i]_LL[%ix%i]",
- width, height,
- ulX, ulY,
- urX, urY,
- lrX, lrY,
- llX, llY);
- fRadii[0].set(SkIntToScalar(ulX), SkIntToScalar(ulY));
- fRadii[1].set(SkIntToScalar(urX), SkIntToScalar(urY));
- fRadii[2].set(SkIntToScalar(lrX), SkIntToScalar(lrY));
- fRadii[3].set(SkIntToScalar(llX), SkIntToScalar(llY));
+ BlurRoundRectBench(int width, int height, int cornerRadius)
+ : fName("blurroundrect") {
+ fName.appendf("_WH[%ix%i]_cr[%i]", width, height, cornerRadius);
+ SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
+ fRRect.setRectXY(r, SkIntToScalar(cornerRadius), SkIntToScalar(cornerRadius));
}
virtual const char* onGetName() SK_OVERRIDE {
@@ -50,60 +35,59 @@ public:
}
virtual SkIPoint onGetSize() SK_OVERRIDE {
- return SkIPoint::Make(fWidth, fHeight);
+ return SkIPoint::Make(SkScalarCeilToInt(fRRect.rect().width()),
+ SkScalarCeilToInt(fRRect.rect().height()));
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
- for (int i = 0; i < this->getLoops(); i++) {
- SkLayerDrawLooper* looper = new SkLayerDrawLooper;
- {
- SkLayerDrawLooper::LayerInfo info;
- info.fFlagsMask = 0;
- info.fPaintBits = 40;
- info.fColorMode = SkXfermode::kSrc_Mode;
- info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0));
- info.fPostTranslate = false;
- SkPaint* paint = looper->addLayerOnTop(info);
- SkMaskFilter* maskFilter = SkBlurMaskFilter::Create(SK_ScalarHalf,
- SkBlurMaskFilter::kNormal_BlurStyle,
- SkBlurMaskFilter::kHighQuality_BlurFlag);
- paint->setMaskFilter(maskFilter)->unref();
- SkColorFilter* colorFilter = SkColorFilter::CreateModeFilter(SK_ColorLTGRAY,
- SkXfermode::kSrcIn_Mode);
- paint->setColorFilter(colorFilter)->unref();
- paint->setColor(SK_ColorGRAY);
- }
- {
- SkLayerDrawLooper::LayerInfo info;
- looper->addLayerOnTop(info);
- }
- SkPaint paint;
- SkRect rect = SkRect::MakeWH(SkIntToScalar(fWidth), SkIntToScalar(fHeight));
- canvas->drawRect(rect, paint);
+ SkLayerDrawLooper* looper = new SkLayerDrawLooper;
+ {
+ SkLayerDrawLooper::LayerInfo info;
+ info.fFlagsMask = 0;
+ info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit
+ | SkLayerDrawLooper::kColorFilter_Bit;
+ info.fColorMode = SkXfermode::kSrc_Mode;
+ info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0));
+ info.fPostTranslate = false;
+ SkPaint* paint = looper->addLayerOnTop(info);
+ SkMaskFilter* maskFilter = SkBlurMaskFilter::Create(SK_ScalarHalf,
+ SkBlurMaskFilter::kNormal_BlurStyle,
+ SkBlurMaskFilter::kHighQuality_BlurFlag);
+ paint->setMaskFilter(maskFilter)->unref();
+ SkColorFilter* colorFilter = SkColorFilter::CreateModeFilter(SK_ColorLTGRAY,
+ SkXfermode::kSrcIn_Mode);
+ paint->setColorFilter(colorFilter)->unref();
+ paint->setColor(SK_ColorGRAY);
+ }
+ {
+ SkLayerDrawLooper::LayerInfo info;
+ looper->addLayerOnTop(info);
+ }
+ SkPaint dullPaint;
+ dullPaint.setAntiAlias(true);
- paint.setLooper(looper)->unref();
- paint.setAntiAlias(true);
- paint.setColor(SK_ColorCYAN);
+ SkPaint loopedPaint;
+ loopedPaint.setLooper(looper)->unref();
+ loopedPaint.setAntiAlias(true);
+ loopedPaint.setColor(SK_ColorCYAN);
- SkRRect rrect;
- rrect.setRectRadii(rect, fRadii);
- canvas->drawRRect(rrect, paint);
+ for (int i = 0; i < this->getLoops(); i++) {
+ canvas->drawRect(fRRect.rect(), dullPaint);
+ canvas->drawRRect(fRRect, loopedPaint);
}
}
private:
- SkString fName;
- const int fWidth;
- const int fHeight;
- SkVector fRadii[4];
- typedef SkBenchmark INHERITED;
+ SkString fName;
+ SkRRect fRRect;
+
+ typedef SkBenchmark INHERITED;
};
// Create one with dimensions/rounded corners based on the skp
-DEF_BENCH(return new BlurRoundRectBench(600, 5514, 6, 6, 6, 6, 6, 6, 6, 6);)
+DEF_BENCH(return new BlurRoundRectBench(600, 5514, 6);)
// Same radii, much smaller rectangle
-DEF_BENCH(return new BlurRoundRectBench(100, 100, 6, 6, 6, 6, 6, 6, 6, 6);)
-// Rounded rect with two opposite corners with large radii, the other two
-// small.
-DEF_BENCH(return new BlurRoundRectBench(100, 100, 30, 30, 10, 10, 30, 30, 10, 10);)
-DEF_BENCH(return new BlurRoundRectBench(100, 100, 90, 90, 90, 90, 90, 90, 90, 90);)
+DEF_BENCH(return new BlurRoundRectBench(100, 100, 6);)
+// Other radii options
+DEF_BENCH(return new BlurRoundRectBench(100, 100, 30);)
+DEF_BENCH(return new BlurRoundRectBench(100, 100, 90);)