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

Side by Side Diff: gm/blurs.cpp

Issue 253833002: move common blur types into central header (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « gm/blurroundrect.cpp ('k') | gm/circles.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
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 11
12 namespace skiagm { 12 namespace skiagm {
13 13
14 class BlursGM : public GM { 14 class BlursGM : public GM {
15 public: 15 public:
16 BlursGM() { 16 BlursGM() {
17 this->setBGColor(0xFFDDDDDD); 17 this->setBGColor(0xFFDDDDDD);
18 } 18 }
19 19
20 protected: 20 protected:
21 virtual SkString onShortName() { 21 virtual SkString onShortName() {
22 return SkString("blurs"); 22 return SkString("blurs");
23 } 23 }
24 24
25 virtual SkISize onISize() { 25 virtual SkISize onISize() {
26 return make_isize(700, 500); 26 return make_isize(700, 500);
27 } 27 }
28 28
29 virtual void onDraw(SkCanvas* canvas) { 29 virtual void onDraw(SkCanvas* canvas) {
30 SkBlurMaskFilter::BlurStyle NONE = SkBlurMaskFilter::BlurStyle(-999); 30 SkBlurStyle NONE = SkBlurStyle(-999);
31 static const struct { 31 static const struct {
32 SkBlurMaskFilter::BlurStyle fStyle; 32 SkBlurStyle fStyle;
33 int fCx, fCy; 33 int fCx, fCy;
34 } gRecs[] = { 34 } gRecs[] = {
35 { NONE, 0, 0 }, 35 { NONE, 0, 0 },
36 { SkBlurMaskFilter::kInner_BlurStyle, -1, 0 }, 36 { kInner_SkBlurStyle, -1, 0 },
37 { SkBlurMaskFilter::kNormal_BlurStyle, 0, 1 }, 37 { kNormal_SkBlurStyle, 0, 1 },
38 { SkBlurMaskFilter::kSolid_BlurStyle, 0, -1 }, 38 { kSolid_SkBlurStyle, 0, -1 },
39 { SkBlurMaskFilter::kOuter_BlurStyle, 1, 0 }, 39 { kOuter_SkBlurStyle, 1, 0 },
40 }; 40 };
41 41
42 SkPaint paint; 42 SkPaint paint;
43 paint.setAntiAlias(true); 43 paint.setAntiAlias(true);
44 paint.setTextSize(SkIntToScalar(25)); 44 paint.setTextSize(SkIntToScalar(25));
45 canvas->translate(SkIntToScalar(-40), SkIntToScalar(0)); 45 canvas->translate(SkIntToScalar(-40), SkIntToScalar(0));
46 46
47 SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag; 47 SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag;
48 for (int j = 0; j < 2; j++) { 48 for (int j = 0; j < 2; j++) {
49 canvas->save(); 49 canvas->save();
50 paint.setColor(SK_ColorBLUE); 50 paint.setColor(SK_ColorBLUE);
51 for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { 51 for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) {
52 if (gRecs[i].fStyle != NONE) { 52 if (gRecs[i].fStyle != NONE) {
53 SkMaskFilter* mf = SkBlurMaskFilter::Create(gRecs[i].fStyle, 53 SkMaskFilter* mf = SkBlurMaskFilter::Create(gRecs[i].fStyle,
54 SkBlurMask::ConvertRadiusToSigma(SkIn tToScalar(20)), 54 SkBlurMask::ConvertRadiusToSigma(SkIn tToScalar(20)),
55 flags); 55 flags);
56 paint.setMaskFilter(mf)->unref(); 56 paint.setMaskFilter(mf)->unref();
57 } else { 57 } else {
58 paint.setMaskFilter(NULL); 58 paint.setMaskFilter(NULL);
59 } 59 }
60 canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100), 60 canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100),
61 SkIntToScalar(200 + gRecs[i].fCy*100), 61 SkIntToScalar(200 + gRecs[i].fCy*100),
62 SkIntToScalar(50), 62 SkIntToScalar(50),
63 paint); 63 paint);
64 } 64 }
65 // draw text 65 // draw text
66 { 66 {
67 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN ormal_BlurStyle, 67 SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
68 SkBlurMask::ConvertRadiusToSigma(SkIn tToScalar(4)), 68 SkBlurMask::ConvertRadiusToSigma(SkIn tToScalar(4)),
69 flags); 69 flags);
70 paint.setMaskFilter(mf)->unref(); 70 paint.setMaskFilter(mf)->unref();
71 SkScalar x = SkIntToScalar(70); 71 SkScalar x = SkIntToScalar(70);
72 SkScalar y = SkIntToScalar(400); 72 SkScalar y = SkIntToScalar(400);
73 paint.setColor(SK_ColorBLACK); 73 paint.setColor(SK_ColorBLACK);
74 canvas->drawText("Hamburgefons Style", 18, x, y, paint); 74 canvas->drawText("Hamburgefons Style", 18, x, y, paint);
75 canvas->drawText("Hamburgefons Style", 18, 75 canvas->drawText("Hamburgefons Style", 18,
76 x, y + SkIntToScalar(50), paint); 76 x, y + SkIntToScalar(50), paint);
77 paint.setMaskFilter(NULL); 77 paint.setMaskFilter(NULL);
(...skipping 11 matching lines...) Expand all
89 private: 89 private:
90 typedef GM INHERITED; 90 typedef GM INHERITED;
91 }; 91 };
92 92
93 ////////////////////////////////////////////////////////////////////////////// 93 //////////////////////////////////////////////////////////////////////////////
94 94
95 static GM* MyFactory(void*) { return new BlursGM; } 95 static GM* MyFactory(void*) { return new BlursGM; }
96 static GMRegistry reg(MyFactory); 96 static GMRegistry reg(MyFactory);
97 97
98 } 98 }
OLDNEW
« no previous file with comments | « gm/blurroundrect.cpp ('k') | gm/circles.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698