Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3909)

Unified Diff: bench/BlurRoundRectBench.cpp

Issue 52793005: Add gms and benchmarks for drawing blurry round rects. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: More test cases Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gm/blurroundrect.cpp » ('j') | gm/blurroundrect.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/BlurRoundRectBench.cpp
diff --git a/bench/BlurRoundRectBench.cpp b/bench/BlurRoundRectBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..486de3d4d01b69e2ac13a9370f7515802e0540bf
--- /dev/null
+++ b/bench/BlurRoundRectBench.cpp
@@ -0,0 +1,109 @@
+/*
+* Copyright 2013 Google Inc.
+*
+* Use of this source code is governed by a BSD-style license that can be
+* found in the LICENSE file.
+*/
+
+#include "SkBenchmark.h"
+#include "SkBlurMask.h"
+#include "SkBlurMaskFilter.h"
+#include "SkCanvas.h"
+#include "SkColorFilter.h"
+#include "SkLayerDrawLooper.h"
+#include "SkPaint.h"
+#include "SkPath.h"
+#include "SkPoint.h"
+#include "SkRect.h"
+#include "SkRRect.h"
+#include "SkString.h"
+#include "SkXfermode.h"
+
robertphillips 2013/11/05 16:31:03 // Large blurred RR appear frequently on web pages
scroggo 2013/11/05 20:45:41 Done.
+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));
+ }
+
+ virtual const char* onGetName() SK_OVERRIDE {
+ return fName.c_str();
+ }
+
+ virtual SkIPoint onGetSize() SK_OVERRIDE {
+ return SkIPoint::Make(fWidth, fHeight);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
robertphillips 2013/11/05 16:31:03 It seems like the paint/looper/etc. should be crea
scroggo 2013/11/05 20:45:41 Done.
+ for (int i = 0; i < this->getLoops(); i++) {
+ SkLayerDrawLooper* looper = new SkLayerDrawLooper;
+ {
+ SkLayerDrawLooper::LayerInfo info;
+ info.fFlagsMask = 0;
robertphillips 2013/11/05 16:31:03 40?
scroggo 2013/11/05 20:45:41 Done.
+ 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();
robertphillips 2013/11/05 16:31:03 4279308561?
scroggo 2013/11/05 20:45:41 These were taken from the SKP. They also break war
+ SkColorFilter* colorFilter = SkColorFilter::CreateModeFilter(4279308561,
+ SkXfermode::kSrcIn_Mode);
+ paint->setColorFilter(colorFilter)->unref();
robertphillips 2013/11/05 16:31:03 4278190080?
scroggo 2013/11/05 20:45:41 same
+ paint->setColor(4278190080);
+ }
+ {
+ SkLayerDrawLooper::LayerInfo info;
+ looper->addLayerOnTop(info);
+ }
+ SkPaint paint;
+ SkRect rect = SkRect::MakeWH(fWidth, fHeight);
+ canvas->drawRect(rect, paint);
+
+ paint.setLooper(looper)->unref();
robertphillips 2013/11/05 16:31:03 4293848814?
scroggo 2013/11/05 20:45:41 same
+ paint.setColor(4293848814);
+ paint.setAntiAlias(true);
+
+ SkRRect rrect;
+ rrect.setRectRadii(rect, fRadii);
+ canvas->drawRRect(rrect, paint);
+ }
+ }
+
+private:
robertphillips 2013/11/05 16:31:03 OCD me says these should be lined up.
scroggo 2013/11/05 20:45:41 Done.
+ SkString fName;
+ const int fWidth;
+ const int fHeight;
+ SkVector fRadii[4];
+ 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);)
+// 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);)
« no previous file with comments | « no previous file | gm/blurroundrect.cpp » ('j') | gm/blurroundrect.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698