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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | gm/blurroundrect.cpp » ('j') | gm/blurroundrect.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkBenchmark.h"
9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h"
11 #include "SkCanvas.h"
12 #include "SkColorFilter.h"
13 #include "SkLayerDrawLooper.h"
14 #include "SkPaint.h"
15 #include "SkPath.h"
16 #include "SkPoint.h"
17 #include "SkRect.h"
18 #include "SkRRect.h"
19 #include "SkString.h"
20 #include "SkXfermode.h"
21
robertphillips 2013/11/05 16:31:03 // Large blurred RR appear frequently on web pages
scroggo 2013/11/05 20:45:41 Done.
22 class BlurRoundRectBench : public SkBenchmark {
23 public:
24 BlurRoundRectBench(int width, int height,
25 // X and Y radii for the upper left corner
26 int ulX, int ulY,
27 // X and Y radii for the upper right corner
28 int urX, int urY,
29 // X and Y radii for the lower right corner
30 int lrX, int lrY,
31 // X and Y radii for the lower left corner
32 int llX, int llY)
33 : fName("blurroundrect")
34 , fWidth(width)
35 , fHeight(height) {
36 fName.appendf("_WH[%ix%i]_UL[%ix%i]_UR[%ix%i]_LR[%ix%i]_LL[%ix%i]",
37 width, height,
38 ulX, ulY,
39 urX, urY,
40 lrX, lrY,
41 llX, llY);
42 fRadii[0].set(SkIntToScalar(ulX), SkIntToScalar(ulY));
43 fRadii[1].set(SkIntToScalar(urX), SkIntToScalar(urY));
44 fRadii[2].set(SkIntToScalar(lrX), SkIntToScalar(lrY));
45 fRadii[3].set(SkIntToScalar(llX), SkIntToScalar(llY));
46 }
47
48 virtual const char* onGetName() SK_OVERRIDE {
49 return fName.c_str();
50 }
51
52 virtual SkIPoint onGetSize() SK_OVERRIDE {
53 return SkIPoint::Make(fWidth, fHeight);
54 }
55
56 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.
57 for (int i = 0; i < this->getLoops(); i++) {
58 SkLayerDrawLooper* looper = new SkLayerDrawLooper;
59 {
60 SkLayerDrawLooper::LayerInfo info;
61 info.fFlagsMask = 0;
robertphillips 2013/11/05 16:31:03 40?
scroggo 2013/11/05 20:45:41 Done.
62 info.fPaintBits = 40;
63 info.fColorMode = SkXfermode::kSrc_Mode;
64 info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0) );
65 info.fPostTranslate = false;
66 SkPaint* paint = looper->addLayerOnTop(info);
67 SkMaskFilter* maskFilter = SkBlurMaskFilter::Create(SK_ScalarHal f,
68 SkBlurMaskFilter::kNormal_BlurStyle,
69 SkBlurMaskFilter::kHighQuality_BlurFlag);
70 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
71 SkColorFilter* colorFilter = SkColorFilter::CreateModeFilter(427 9308561,
72 SkXfermode::kSrcIn_Mode);
73 paint->setColorFilter(colorFilter)->unref();
robertphillips 2013/11/05 16:31:03 4278190080?
scroggo 2013/11/05 20:45:41 same
74 paint->setColor(4278190080);
75 }
76 {
77 SkLayerDrawLooper::LayerInfo info;
78 looper->addLayerOnTop(info);
79 }
80 SkPaint paint;
81 SkRect rect = SkRect::MakeWH(fWidth, fHeight);
82 canvas->drawRect(rect, paint);
83
84 paint.setLooper(looper)->unref();
robertphillips 2013/11/05 16:31:03 4293848814?
scroggo 2013/11/05 20:45:41 same
85 paint.setColor(4293848814);
86 paint.setAntiAlias(true);
87
88 SkRRect rrect;
89 rrect.setRectRadii(rect, fRadii);
90 canvas->drawRRect(rrect, paint);
91 }
92 }
93
94 private:
robertphillips 2013/11/05 16:31:03 OCD me says these should be lined up.
scroggo 2013/11/05 20:45:41 Done.
95 SkString fName;
96 const int fWidth;
97 const int fHeight;
98 SkVector fRadii[4];
99 typedef SkBenchmark INHERITED;
100 };
101
102 // Create one with dimensions/rounded corners based on the skp
103 DEF_BENCH(return new BlurRoundRectBench(600, 5514, 6, 6, 6, 6, 6, 6, 6, 6);)
104 // Same radii, much smaller rectangle
105 DEF_BENCH(return new BlurRoundRectBench(100, 100, 6, 6, 6, 6, 6, 6, 6, 6);)
106 // Rounded rect with two opposite corners with large radii, the other two
107 // small.
108 DEF_BENCH(return new BlurRoundRectBench(100, 100, 30, 30, 10, 10, 30, 30, 10, 10 );)
109 DEF_BENCH(return new BlurRoundRectBench(100, 100, 90, 90, 90, 90, 90, 90, 90, 90 );)
OLDNEW
« 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