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

Side by Side Diff: gm/blurroundrect.cpp

Issue 1562093002: Remove work from constructors to facilitate debugging. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use valid width and height. Created 4 years, 11 months 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
« no previous file with comments | « no previous file | gm/composeshader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkColorFilter.h" 12 #include "SkColorFilter.h"
13 #include "SkLayerDrawLooper.h" 13 #include "SkLayerDrawLooper.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15 #include "SkPath.h" 15 #include "SkPath.h"
16 #include "SkPoint.h" 16 #include "SkPoint.h"
17 #include "SkRect.h" 17 #include "SkRect.h"
18 #include "SkRRect.h" 18 #include "SkRRect.h"
19 #include "SkString.h" 19 #include "SkString.h"
20 #include "SkXfermode.h" 20 #include "SkXfermode.h"
21 21
22 // This GM mimics a blurred RR seen in the wild. 22 // This GM mimics a blurred RR seen in the wild.
23 class BlurRoundRectGM : public skiagm::GM { 23 class BlurRoundRectGM : public skiagm::GM {
24 public: 24 public:
25 BlurRoundRectGM(int width, int height, int radius)
26 : fName("blurroundrect")
27 {
28 SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
29 fRRect.setRectXY(r, SkIntToScalar(radius), SkIntToScalar(radius));
30 fName.appendf("-WH-%ix%i-corner-%i", width, height, radius);
31 }
32
33 BlurRoundRectGM(int width, int height) 25 BlurRoundRectGM(int width, int height)
34 : fName("blurroundrect") { 26 : fName("blurroundrect"), fWidth(width), fHeight(height) {
35 fName.appendf("-WH-%ix%i-unevenCorners", width, height); 27 fName.appendf("-WH-%ix%i-unevenCorners", width, height);
36 SkVector radii[4];
37 radii[0].set(SkIntToScalar(30), SkIntToScalar(30));
38 radii[1].set(SkIntToScalar(10), SkIntToScalar(10));
39 radii[2].set(SkIntToScalar(30), SkIntToScalar(30));
40 radii[3].set(SkIntToScalar(10), SkIntToScalar(10));
41 SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
42 fRRect.setRectRadii(r, radii);
43 } 28 }
44 29
45 SkString onShortName() override { 30 SkString onShortName() override {
46 return fName; 31 return fName;
47 } 32 }
48 33
49 SkISize onISize() override { 34 SkISize onISize() override {
50 return SkISize::Make(SkScalarCeilToInt(fRRect.rect().width()), 35 return SkISize::Make(fWidth, fHeight);
51 SkScalarCeilToInt(fRRect.rect().height())); 36 }
37
38 void onOnceBeforeDraw() override {
39 SkVector radii[4];
40 radii[0].set(SkIntToScalar(30), SkIntToScalar(30));
41 radii[1].set(SkIntToScalar(10), SkIntToScalar(10));
42 radii[2].set(SkIntToScalar(30), SkIntToScalar(30));
43 radii[3].set(SkIntToScalar(10), SkIntToScalar(10));
44 SkRect r = SkRect::MakeWH(SkIntToScalar(fWidth), SkIntToScalar(fHeight)) ;
45 fRRect.setRectRadii(r, radii);
52 } 46 }
53 47
54 void onDraw(SkCanvas* canvas) override { 48 void onDraw(SkCanvas* canvas) override {
55 SkLayerDrawLooper::Builder looperBuilder; 49 SkLayerDrawLooper::Builder looperBuilder;
56 { 50 {
57 SkLayerDrawLooper::LayerInfo info; 51 SkLayerDrawLooper::LayerInfo info;
58 info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit 52 info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit
59 | SkLayerDrawLooper::kColorFilter_Bit; 53 | SkLayerDrawLooper::kColorFilter_Bit;
60 info.fColorMode = SkXfermode::kSrc_Mode; 54 info.fColorMode = SkXfermode::kSrc_Mode;
61 info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); 55 info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0));
(...skipping 20 matching lines...) Expand all
82 paint.setLooper(looperBuilder.detachLooper())->unref(); 76 paint.setLooper(looperBuilder.detachLooper())->unref();
83 paint.setColor(SK_ColorCYAN); 77 paint.setColor(SK_ColorCYAN);
84 paint.setAntiAlias(true); 78 paint.setAntiAlias(true);
85 79
86 canvas->drawRRect(fRRect, paint); 80 canvas->drawRRect(fRRect, paint);
87 } 81 }
88 82
89 private: 83 private:
90 SkString fName; 84 SkString fName;
91 SkRRect fRRect; 85 SkRRect fRRect;
86 int fWidth, fHeight;
92 87
93 typedef skiagm::GM INHERITED; 88 typedef skiagm::GM INHERITED;
94 }; 89 };
95 90
96 #include "SkGradientShader.h" 91 #include "SkGradientShader.h"
97 /* 92 /*
98 * Spits out a dummy gradient to test blur with shader on paint 93 * Spits out a dummy gradient to test blur with shader on paint
99 */ 94 */
100 static SkShader* MakeRadial() { 95 static SkShader* MakeRadial() {
101 SkPoint pts[2] = { 96 SkPoint pts[2] = {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // TODO(scroggo): Disabled in an attempt to rememdy 176 // TODO(scroggo): Disabled in an attempt to rememdy
182 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai ling GenerateGMs: 177 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai ling GenerateGMs:
183 // ran wrong number of tests') 178 // ran wrong number of tests')
184 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) 179 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);)
185 180
186 // Rounded rect with two opposite corners with large radii, the other two 181 // Rounded rect with two opposite corners with large radii, the other two
187 // small. 182 // small.
188 DEF_GM(return new BlurRoundRectGM(100, 100);) 183 DEF_GM(return new BlurRoundRectGM(100, 100);)
189 184
190 DEF_GM(return new SimpleBlurRoundRectGM();) 185 DEF_GM(return new SimpleBlurRoundRectGM();)
OLDNEW
« no previous file with comments | « no previous file | gm/composeshader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698